|
19 | 19 | # Quick-start development settings - unsuitable for production
|
20 | 20 | # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
|
21 | 21 |
|
22 |
| -# SECURITY WARNING: keep the secret key used in production secret! |
23 |
| -SECRET_KEY = "django-insecure-w!h85bp^$e8gm%c23r!0%9i7yzd=6w$s&ic+6!%306&kj8@k*5" |
| 22 | +SECRET_KEY = os.environ["SECRET_KEY"] |
24 | 23 |
|
25 | 24 | # SECURITY WARNING: don't run with debug turned on in production!
|
26 |
| -DEBUG = True |
| 25 | +DEBUG = bool(os.getenv("DEBUG", "")) |
27 | 26 |
|
28 |
| -ALLOWED_HOSTS = [] |
| 27 | +ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "").split() |
| 28 | +USE_X_FORWARDED_HOST = bool(os.getenv("USE_X_FORWARDED_HOST", "")) |
| 29 | +CSRF_TRUSTED_ORIGINS = os.getenv("CSRF_TRUSTED_ORIGINS", "").split() |
29 | 30 |
|
30 | 31 | # Application definition
|
31 | 32 |
|
|
35 | 36 | "django.contrib.contenttypes",
|
36 | 37 | "django.contrib.sessions",
|
37 | 38 | "django.contrib.messages",
|
| 39 | + "whitenoise.runserver_nostatic", |
38 | 40 | "django.contrib.staticfiles",
|
39 |
| - "django_extensions", |
40 | 41 | "users",
|
41 | 42 | "general",
|
42 | 43 | ]
|
| 44 | +if DEBUG: |
| 45 | + INSTALLED_APPS += [ |
| 46 | + "django_extensions", |
| 47 | + ] |
43 | 48 |
|
44 | 49 | AUTH_USER_MODEL = "users.CustomUser"
|
45 | 50 |
|
46 | 51 | MIDDLEWARE = [
|
47 | 52 | "django.middleware.security.SecurityMiddleware",
|
| 53 | + "whitenoise.middleware.WhiteNoiseMiddleware", |
48 | 54 | "django.contrib.sessions.middleware.SessionMiddleware",
|
49 | 55 | "django.middleware.common.CommonMiddleware",
|
50 | 56 | "django.middleware.csrf.CsrfViewMiddleware",
|
|
82 | 88 | DATABASES = {
|
83 | 89 | "default": {
|
84 | 90 | "ENGINE": "django.db.backends.postgresql",
|
85 |
| - "HOST": os.environ.get("DJANGO_DB_HOST"), |
86 |
| - "PORT": os.environ.get("DJANGO_DB_PORT"), |
87 |
| - "NAME": os.environ.get("DJANGO_DB_NAME"), |
88 |
| - "USER": os.environ.get("DJANGO_DB_USER"), |
89 |
| - "PASSWORD": os.environ.get("DJANGO_DB_PASSWORD"), |
| 91 | + "HOST": os.environ.get("DB_HOST"), |
| 92 | + "PORT": os.environ.get("DB_PORT"), |
| 93 | + "NAME": os.environ.get("DB_NAME"), |
| 94 | + "USER": os.environ.get("DB_USER"), |
| 95 | + "PASSWORD": os.environ.get("DB_PASSWORD"), |
90 | 96 | }
|
91 | 97 | }
|
92 | 98 |
|
|
122 | 128 | # Static files (CSS, JavaScript, Images)
|
123 | 129 | # https://docs.djangoproject.com/en/5.0/howto/static-files/
|
124 | 130 |
|
125 |
| -STATIC_URL = "static/" |
| 131 | +STATIC_URL = "/static/" |
126 | 132 | STATICFILES_DIRS = [
|
127 | 133 | BASE_DIR / "static",
|
128 | 134 | ]
|
129 | 135 |
|
| 136 | +STATIC_ROOT = BASE_DIR / "static_files" |
| 137 | +STORAGES = { |
| 138 | + "default": { |
| 139 | + "BACKEND": "django.core.files.storage.FileSystemStorage", |
| 140 | + }, |
| 141 | + "staticfiles": { |
| 142 | + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", |
| 143 | + }, |
| 144 | +} |
| 145 | + |
130 | 146 | # Default primary key field type
|
131 | 147 | # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
|
132 | 148 |
|
|
0 commit comments