""" Django settings for config project. Generated by 'django-admin startproject' using Django 2.2.3. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os from decouple import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config( "SECRET_KEY", default="o!ld8nrt4vc*h1zoey*wj48x*q0#ss12h=+zh)kk^6b3aygg=!" ) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=True, cast=bool) ALLOWED_HOSTS = ["127.0.0.1", "your-domain.com"] # change the default user models to our custom model AUTH_USER_MODEL = "accounts.User" # Application definition DJANGO_APPS = [ "jet.dashboard", "jet", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", ] # Third party apps THIRD_PARTY_APPS = [ "crispy_forms", "rest_framework", ] # Custom apps PROJECT_APPS = [ "app.apps.AppConfig", "accounts.apps.AccountsConfig", "course.apps.CourseConfig", "result.apps.ResultConfig", "search.apps.SearchConfig", "quiz.apps.QuizConfig", "payments.apps.PaymentsConfig", ] # Combine all apps INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + PROJECT_APPS MIDDLEWARE = [ "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", "whitenoise.middleware.WhiteNoiseMiddleware", # whitenoise to serve static files ] ROOT_URLCONF = "config.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [os.path.join(BASE_DIR, "templates")], "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", # 'django.template.context_processors.i18n', # 'django.template.context_processors.media', # 'django.template.context_processors.static', # 'django.template.context_processors.tz', ], }, }, ] WSGI_APPLICATION = "config.wsgi.application" ASGI_APPLICATION = "config.asgi.application" # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases # DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # } # } # ----------------------------- # NOTE: Some model fields may not work on sqlite db, # so consider using postgresql instead DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": config("DB_NAME"), "USER": config("DB_USER"), "PASSWORD": config("DB_PASSWORD"), "HOST": config("DB_HOST", default="localhost"), "PORT": config("DB_PORT", default=5432), } } # https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-DEFAULT_AUTO_FIELD DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" # Password validation # https://docs.djangoproject.com/en/2.2/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/2.2/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ # https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = "/static/" # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] # https://docs.djangoproject.com/en/dev/ref/settings/#static-root STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] # Media files config MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR, "media") # ----------------------------------- # E-mail configuration EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = "smtp.gmail.com" # Gmail as the email host, but you can change it EMAIL_PORT = config("EMAIL_PORT", default=587) EMAIL_USE_TLS = True EMAIL_HOST_USER = config("USER_EMAIL") EMAIL_HOST_PASSWORD = config("USER_PASSWORD") # crispy config CRISPY_TEMPLATE_PACK = "bootstrap4" LOGIN_REDIRECT_URL = "/" LOGOUT_REDIRECT_URL = "/" # DRF setup REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES": [ "rest_framework.permissions.IsAuthenticated", ], "DEFAULT_AUTHENTICATION_CLASSES": [ "rest_framework.authentication.SessionAuthentication", "rest_framework.authentication.BasicAuthentication", ], } # Strip payment config STRIPE_SECRET_KEY = config("STRIPE_SECRET_KEY", default="") STRIPE_PUBLISHABLE_KEY = config("STRIPE_PUBLISHABLE_KEY", default="") # LOGGING # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#logging # See https://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { "version": 1, "disable_existing_loggers": False, "formatters": { "verbose": { "format": "%(levelname)s %(asctime)s %(module)s " "%(process)d %(thread)d %(message)s" } }, "handlers": { "console": { "level": "DEBUG", "class": "logging.StreamHandler", "formatter": "verbose", } }, "root": {"level": "INFO", "handlers": ["console"]}, } # WhiteNoise configuration STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"