settings.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. from pathlib import Path
  2. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  3. BASE_DIR = Path(__file__).resolve().parent.parent
  4. # Quick-start development settings - unsuitable for production
  5. # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
  6. # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
  7. # SECURITY WARNING: keep the secret key used in production secret!
  8. SECRET_KEY = "django-insecure-0peo@#x9jur3!h$ryje!$879xww8y1y66jx!%*#ymhg&jkozs2"
  9. # https://docs.djangoproject.com/en/dev/ref/settings/#debug
  10. # SECURITY WARNING: don't run with debug turned on in production!
  11. DEBUG = True
  12. # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
  13. ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
  14. # Application definition
  15. # https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
  16. INSTALLED_APPS = [
  17. "django.contrib.admin",
  18. "django.contrib.auth",
  19. "django.contrib.contenttypes",
  20. "django.contrib.sessions",
  21. "django.contrib.messages",
  22. "whitenoise.runserver_nostatic",
  23. "django.contrib.staticfiles",
  24. "django.contrib.sites",
  25. # Third-party
  26. "allauth",
  27. "allauth.account",
  28. "crispy_forms",
  29. "crispy_bootstrap5",
  30. "debug_toolbar",
  31. # Local
  32. "accounts",
  33. "pages",
  34. ]
  35. # https://docs.djangoproject.com/en/dev/ref/settings/#middleware
  36. MIDDLEWARE = [
  37. "django.middleware.security.SecurityMiddleware",
  38. "whitenoise.middleware.WhiteNoiseMiddleware", # WhiteNoise
  39. "django.contrib.sessions.middleware.SessionMiddleware",
  40. "django.middleware.common.CommonMiddleware",
  41. "debug_toolbar.middleware.DebugToolbarMiddleware", # Django Debug Toolbar
  42. "django.middleware.csrf.CsrfViewMiddleware",
  43. "django.contrib.auth.middleware.AuthenticationMiddleware",
  44. "django.contrib.messages.middleware.MessageMiddleware",
  45. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  46. "allauth.account.middleware.AccountMiddleware", # django-allauth
  47. ]
  48. # https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
  49. ROOT_URLCONF = "django_project.urls"
  50. # https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
  51. WSGI_APPLICATION = "django_project.wsgi.application"
  52. # https://docs.djangoproject.com/en/dev/ref/settings/#templates
  53. TEMPLATES = [
  54. {
  55. "BACKEND": "django.template.backends.django.DjangoTemplates",
  56. "DIRS": [BASE_DIR / "templates"],
  57. "APP_DIRS": True,
  58. "OPTIONS": {
  59. "context_processors": [
  60. "django.template.context_processors.debug",
  61. "django.template.context_processors.request",
  62. "django.contrib.auth.context_processors.auth",
  63. "django.contrib.messages.context_processors.messages",
  64. ],
  65. },
  66. },
  67. ]
  68. # https://docs.djangoproject.com/en/dev/ref/settings/#databases
  69. DATABASES = {
  70. "default": {
  71. "ENGINE": "django.db.backends.sqlite3",
  72. "NAME": BASE_DIR / "db.sqlite3",
  73. }
  74. }
  75. # For Docker/PostgreSQL usage uncomment this and comment the DATABASES config above
  76. # DATABASES = {
  77. # "default": {
  78. # "ENGINE": "django.db.backends.postgresql",
  79. # "NAME": "postgres",
  80. # "USER": "postgres",
  81. # "PASSWORD": "postgres",
  82. # "HOST": "db", # set in docker-compose.yml
  83. # "PORT": 5432, # default postgres port
  84. # }
  85. # }
  86. # Password validation
  87. # https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
  88. AUTH_PASSWORD_VALIDATORS = [
  89. {
  90. "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  91. },
  92. {
  93. "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
  94. },
  95. {
  96. "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
  97. },
  98. {
  99. "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
  100. },
  101. ]
  102. # Internationalization
  103. # https://docs.djangoproject.com/en/dev/topics/i18n/
  104. # https://docs.djangoproject.com/en/dev/ref/settings/#language-code
  105. LANGUAGE_CODE = "en-us"
  106. # https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
  107. TIME_ZONE = "UTC"
  108. # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-USE_I18N
  109. USE_I18N = True
  110. # https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
  111. USE_TZ = True
  112. # https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths
  113. LOCALE_PATHS = [BASE_DIR / 'locale']
  114. # Static files (CSS, JavaScript, Images)
  115. # https://docs.djangoproject.com/en/5.0/howto/static-files/
  116. # https://docs.djangoproject.com/en/dev/ref/settings/#static-root
  117. STATIC_ROOT = BASE_DIR / "staticfiles"
  118. # https://docs.djangoproject.com/en/dev/ref/settings/#static-url
  119. STATIC_URL = "/static/"
  120. # https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
  121. STATICFILES_DIRS = [BASE_DIR / "static"]
  122. # https://whitenoise.readthedocs.io/en/latest/django.html
  123. STORAGES = {
  124. "default": {
  125. "BACKEND": "django.core.files.storage.FileSystemStorage",
  126. },
  127. "staticfiles": {
  128. "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
  129. },
  130. }
  131. # Default primary key field type
  132. # https://docs.djangoproject.com/en/stable/ref/settings/#default-auto-field
  133. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  134. # django-crispy-forms
  135. # https://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
  136. CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap5'
  137. CRISPY_TEMPLATE_PACK = "bootstrap5"
  138. # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
  139. EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
  140. # https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
  141. DEFAULT_FROM_EMAIL = "root@localhost"
  142. # django-debug-toolbar
  143. # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html
  144. # https://docs.djangoproject.com/en/dev/ref/settings/#internal-ips
  145. INTERNAL_IPS = ["127.0.0.1"]
  146. # https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model
  147. AUTH_USER_MODEL = "accounts.CustomUser"
  148. # django-allauth config
  149. # https://docs.djangoproject.com/en/dev/ref/settings/#site-id
  150. SITE_ID = 1
  151. # https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
  152. LOGIN_REDIRECT_URL = "home"
  153. # https://django-allauth.readthedocs.io/en/latest/views.html#logout-account-logout
  154. ACCOUNT_LOGOUT_REDIRECT_URL = "home"
  155. # https://django-allauth.readthedocs.io/en/latest/installation.html?highlight=backends
  156. AUTHENTICATION_BACKENDS = (
  157. "django.contrib.auth.backends.ModelBackend",
  158. "allauth.account.auth_backends.AuthenticationBackend",
  159. )
  160. # https://django-allauth.readthedocs.io/en/latest/configuration.html
  161. ACCOUNT_SESSION_REMEMBER = True
  162. ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False
  163. ACCOUNT_USERNAME_REQUIRED = False
  164. ACCOUNT_AUTHENTICATION_METHOD = "email"
  165. ACCOUNT_EMAIL_REQUIRED = True
  166. ACCOUNT_UNIQUE_EMAIL = True