settings.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import os
  2. from pathlib import Path
  3. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  4. BASE_DIR = Path(__file__).resolve().parent.parent
  5. TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")
  6. STATIC_DIR = (os.path.join(BASE_DIR, "static"),)
  7. # Quick-start development settings - unsuitable for production
  8. # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
  9. # SECURITY WARNING: keep the secret key used in production secret!
  10. SECRET_KEY = os.environ.get("SECRET_KEY")
  11. # SECURITY WARNING: don't run with debug turned on in production!
  12. DEBUG = int(os.environ.get("DEBUG", default=0))
  13. ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")
  14. # Application definition
  15. INSTALLED_APPS = [
  16. "django.contrib.admin",
  17. "django.contrib.auth",
  18. "django.contrib.contenttypes",
  19. "django.contrib.sessions",
  20. "django.contrib.messages",
  21. "django.contrib.staticfiles",
  22. "rest_framework",
  23. 'files',
  24. # 3rd
  25. # Local
  26. ]
  27. MIDDLEWARE = [
  28. "django.middleware.security.SecurityMiddleware",
  29. "django.contrib.sessions.middleware.SessionMiddleware",
  30. "django.middleware.common.CommonMiddleware",
  31. "django.middleware.csrf.CsrfViewMiddleware",
  32. "django.contrib.auth.middleware.AuthenticationMiddleware",
  33. "django.contrib.messages.middleware.MessageMiddleware",
  34. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  35. ]
  36. ROOT_URLCONF = "config.urls"
  37. TEMPLATES = [
  38. {
  39. "BACKEND": "django.template.backends.django.DjangoTemplates",
  40. "DIRS": [TEMPLATE_DIR],
  41. "APP_DIRS": True,
  42. "OPTIONS": {
  43. "context_processors": [
  44. "django.template.context_processors.debug",
  45. "django.template.context_processors.request",
  46. "django.contrib.auth.context_processors.auth",
  47. "django.contrib.messages.context_processors.messages",
  48. ],
  49. },
  50. },
  51. ]
  52. WSGI_APPLICATION = "config.wsgi.application"
  53. # Database
  54. # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
  55. DATABASES = {
  56. "default": {
  57. "ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
  58. "NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"),
  59. "USER": os.environ.get("SQL_USER", "user"),
  60. "PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
  61. "HOST": os.environ.get("SQL_HOST", "localhost"),
  62. "PORT": os.environ.get("SQL_PORT", "5432"),
  63. }
  64. }
  65. # Password validation
  66. # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
  67. AUTH_PASSWORD_VALIDATORS = [
  68. {
  69. "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  70. },
  71. {
  72. "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
  73. },
  74. {
  75. "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
  76. },
  77. {
  78. "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
  79. },
  80. ]
  81. # Internationalization
  82. # https://docs.djangoproject.com/en/3.2/topics/i18n/
  83. LANGUAGE_CODE = "en-us"
  84. TIME_ZONE = "UTC"
  85. USE_I18N = True
  86. USE_L10N = True
  87. USE_TZ = True
  88. # Static files (CSS, JavaScript, Images)
  89. # https://docs.djangoproject.com/en/3.2/howto/static-files/
  90. STATIC_URL = "/static/"
  91. STATIC_ROOT = BASE_DIR / "staticfiles"
  92. STATICFILES_DIRS = STATIC_DIR
  93. MEDIA_URL = "/media/"
  94. MEDIA_ROOT = BASE_DIR / "mediafiles"
  95. # Default primary key field type
  96. # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  97. DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"