Backend
- 최초 설치 관련 안내
- 최초설치 및 실행법 요약
- 구성
- python django 이용
- python 버전 : 3.9.13
- django : 4.0.10
- djangorestframework : 3.14.0
- dj-rest-auth : 4.0.1 (로그인, 비번 찾기 등 기능제공)
- django-allauth : 0.54.0 (회원가입 기능 제공)
- djangorestframework-simplejwt : 5.3.0 (보안 로그인 jwt 토큰 사용)
- django-cors-headers : 4.2.0
- rest_framework_simplejwt : 0.0.2
- pyopenssl : 23.2.0
- django-sendgrid-v5
- django-sslserver : 0.22
- 이메일 전송을 위해 sendgrid 가입 및 설정이 필요.
""" Django's settings for demo project. Generated by 'django-admin startproject' using Django 4.0.10. For more information on this file, see <https://docs.djangoproject.com/en/4.0/topics/settings/> For the full list of settings and their values, see <https://docs.djangoproject.com/en/4.0/ref/settings/> """ from datetime import timedelta from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See <https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/> # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'rest_framework_simplejwt', 'rest_framework_simplejwt.token_blacklist', 'demo_server', 'corsheaders', 'allauth', 'allauth.account', 'allauth.socialaccount', 'dj_rest_auth', 'dj_rest_auth.registration', 'django.contrib.sites' ] AUTH_USER_MODEL = 'demo_server.UserModel' REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', ) } SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=300), 'REFRESH_TOKEN_LIFETIME': timedelta(days=7), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': False, 'UPDATE_LAST_LOGIN': False, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'JWK_URL': None, 'LEEWAY': 0, 'AUTH_HEADER_TYPES': ('Bearer',), 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION', 'USER_ID_FIELD': 'email', 'USER_ID_CLAIM': 'email', 'USER_AUTHENTICATION_RULE': 'rest_framework_simplejwt.authentication.default_user_authentication_rule', 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'TOKEN_USER_CLASS': 'rest_framework_simplejwt.models.TokenUser', 'JTI_CLAIM': 'jti', 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp', 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=50), 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1), } SITE_ID = 1 ACCOUNT_UNIQUE_EMAIL = True ACCOUNT_USER_MODEL_USERNAME_FIELD = None ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_VERIFICATION = 'none' ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 3 EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' EMAIL_HOST = 'smtp.cafe24.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' DEFAULT_FROM_EMAIL = EMAIL_HOST_USER CORS_ORIGIN_ALLOW_ALL = True # <- 모든 호스트 허용 MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'demo.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'demo.wsgi.application' # Database # <https://docs.djangoproject.com/en/4.0/ref/settings/#databases> DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # <https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators> AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # <https://docs.djangoproject.com/en/4.0/topics/i18n/> LANGUAGE_CODE = 'ko' TIME_ZONE = 'Asia/Seoul' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # <https://docs.djangoproject.com/en/4.0/howto/static-files/> STATIC_URL = 'static/' STATIC_ROOT = BASE_DIR / 'static' # Default primary key field type # <https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field>
- python django 이용
- 유저
- superuser :
python manage.py createsuperuser 로 생성