0 1 0
Brett Smith - 13 months ago 2019-09-30 15:19:54
brettcsmith@brettcsmith.org
settings: Set default DATABASES and SECRET_KEY values when DEBUG.
1 file changed with 9 insertions and 8 deletions:
↑ Collapse Diff ↑
...
 
@@ -8,21 +8,20 @@ BASE_DIR = PACKAGE_ROOT
8 8
 

	
9 9
 
DEBUG = bool(int(os.environ.get("DJANGO_DEBUG", "1")))
10 10
 

	
11
 
DATABASES = {
12
 
    "default": {
13
 
        "ENGINE": "django.db.backends.sqlite3",
14
 
        "NAME": os.path.join(PROJECT_ROOT, "dev.db"),
15
 
    }
16
 
}
17
 

	
18 11
 
UNPREPEND_WWW = bool(int(os.environ.get("DJANGO_UNPREPEND_WWW", "0")))
19 12
 

	
20 13
 
APPEND_SLASH = True
21 14
 

	
22 15
 
# HEROKU: Update database configuration with $DATABASE_URL.
16
 
DATABASES = {"default": {}}
23 17
 
import dj_database_url
24 18
 
db_from_env = dj_database_url.config()
25 19
 
DATABASES['default'].update(db_from_env)
20
 
if DEBUG and not DATABASES['default']:
21
 
    DATABASES['default'] = {
22
 
        "ENGINE": "django.db.backends.sqlite3",
23
 
        "NAME": os.path.join(PROJECT_ROOT, "dev.db"),
24
 
    }
26 25
 

	
27 26
 
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "localhost").split()
28 27
 
CANONICAL_HOST = os.environ.get("DJANGO_CANONICAL_HOST", None)
...
 
@@ -112,7 +111,9 @@ AWS_STORAGE_BUCKET_NAME = os.environ.get("DJANGO_AWS_STORAGE_BUCKET_NAME", None)
112 111
 

	
113 112
 

	
114 113
 
# Make this unique, and don't share it with anybody.
115
 
SECRET_KEY = "6r&z0i#!k-thu4nv^zzx!f$fbp(&#2i5mq_^%%@ihu_qxxotl_"
114
 
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '').strip()
115
 
if (not SECRET_KEY) and DEBUG:
116
 
    SECRET_KEY = 'Ae=)D4\V=OFh~C63MJHgpc&6~"p-7>^2ux3#Cr;p^!RGw9.BT}U`pi|b04TDv_NB'
116 117
 

	
117 118
 
TEMPLATES = [
118 119
 
    {
0 comments (0 inline, 0 general)