1
+ """
2
+ Django settings for django_defang project.
3
+
4
+ Generated by 'django-admin startproject' using Django 5.1.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.1/topics/settings/
8
+
9
+ For the full list of settings and their values, see
10
+ https://docs.djangoproject.com/en/5.1/ref/settings/
11
+ """
12
+
13
+ import os
14
+ from pathlib import Path
15
+ import dj_database_url
16
+
17
+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
18
+ BASE_DIR = Path (__file__ ).resolve ().parent .parent
19
+
20
+
21
+ # Quick-start development settings - unsuitable for production
22
+ # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
23
+
24
+ # SECURITY WARNING: keep the secret key used in production secret!
25
+ SECRET_KEY = "django-insecure-c!3+-wtsf@&6+p-z88$fyqr!zrnd@uvi=hi&u00n+ku9&_04rk"
26
+
27
+ # SECURITY WARNING: don't run with debug turned on in production!
28
+ DEBUG = True
29
+
30
+ ALLOWED_HOSTS = []
31
+
32
+ if DEBUG :
33
+ ALLOWED_HOSTS = ["*" ]
34
+
35
+
36
+ # Application definition
37
+
38
+ INSTALLED_APPS = [
39
+ "django.contrib.admin" ,
40
+ "django.contrib.auth" ,
41
+ "django.contrib.contenttypes" ,
42
+ "django.contrib.sessions" ,
43
+ "django.contrib.messages" ,
44
+ "django.contrib.staticfiles" ,
45
+ ]
46
+
47
+ MIDDLEWARE = [
48
+ "django.middleware.security.SecurityMiddleware" ,
49
+ "whitenoise.middleware.WhiteNoiseMiddleware" ,
50
+ "django.contrib.sessions.middleware.SessionMiddleware" ,
51
+ "django.middleware.common.CommonMiddleware" ,
52
+ "django.middleware.csrf.CsrfViewMiddleware" ,
53
+ "django.contrib.auth.middleware.AuthenticationMiddleware" ,
54
+ "django.contrib.messages.middleware.MessageMiddleware" ,
55
+ "django.middleware.clickjacking.XFrameOptionsMiddleware" ,
56
+ ]
57
+
58
+ ROOT_URLCONF = "django_defang.urls"
59
+
60
+ TEMPLATES = [
61
+ {
62
+ "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
63
+ "DIRS" : [],
64
+ "APP_DIRS" : True ,
65
+ "OPTIONS" : {
66
+ "context_processors" : [
67
+ "django.template.context_processors.debug" ,
68
+ "django.template.context_processors.request" ,
69
+ "django.contrib.auth.context_processors.auth" ,
70
+ "django.contrib.messages.context_processors.messages" ,
71
+ ],
72
+ },
73
+ },
74
+ ]
75
+
76
+ WSGI_APPLICATION = "django_defang.wsgi.application"
77
+
78
+
79
+ # Database
80
+ # https://docs.djangoproject.com/en/5.1/ref/settings/#databases
81
+
82
+ DATABASES = {
83
+ # default is a postrgres database load from environment variable POSTGRES_URL
84
+ "default" : dj_database_url .config (
85
+ default = os .environ .get ('POSTGRES_URL' )
86
+ )
87
+ }
88
+
89
+ # Password validation
90
+ # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
91
+
92
+ AUTH_PASSWORD_VALIDATORS = [
93
+ {
94
+ "NAME" : "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" ,
95
+ },
96
+ {
97
+ "NAME" : "django.contrib.auth.password_validation.MinimumLengthValidator" ,
98
+ },
99
+ {
100
+ "NAME" : "django.contrib.auth.password_validation.CommonPasswordValidator" ,
101
+ },
102
+ {
103
+ "NAME" : "django.contrib.auth.password_validation.NumericPasswordValidator" ,
104
+ },
105
+ ]
106
+
107
+
108
+ # Internationalization
109
+ # https://docs.djangoproject.com/en/5.1/topics/i18n/
110
+
111
+ LANGUAGE_CODE = "en-us"
112
+
113
+ TIME_ZONE = "UTC"
114
+
115
+ USE_I18N = True
116
+
117
+ USE_TZ = True
118
+
119
+
120
+ # Static files (CSS, JavaScript, Images)
121
+ # https://docs.djangoproject.com/en/5.1/howto/static-files/
122
+
123
+ STATIC_URL = "static/"
124
+
125
+ STATIC_ROOT = BASE_DIR / "staticfiles"
126
+
127
+ STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
128
+
129
+ # Default primary key field type
130
+ # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
131
+
132
+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
133
+
134
+
135
+ CSRF_TRUSTED_ORIGINS = [
136
+ 'https://*.prod1.defang.dev'
137
+ ]
138
+
139
+ if DEBUG :
140
+ CSRF_TRUSTED_ORIGINS = [
141
+ 'http://localhost:8000' ,
142
+ ]
0 commit comments