settings: Set default DATABASES and SECRET_KEY values when DEBUG.

This commit is contained in:
Brett Smith 2019-09-30 10:49:14 -04:00
parent f2cb50a848
commit ff6da2e15e

View file

@ -8,21 +8,20 @@ BASE_DIR = PACKAGE_ROOT
DEBUG = bool(int(os.environ.get("DJANGO_DEBUG", "1"))) DEBUG = bool(int(os.environ.get("DJANGO_DEBUG", "1")))
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(PROJECT_ROOT, "dev.db"),
}
}
UNPREPEND_WWW = bool(int(os.environ.get("DJANGO_UNPREPEND_WWW", "0"))) UNPREPEND_WWW = bool(int(os.environ.get("DJANGO_UNPREPEND_WWW", "0")))
APPEND_SLASH = True APPEND_SLASH = True
# HEROKU: Update database configuration with $DATABASE_URL. # HEROKU: Update database configuration with $DATABASE_URL.
DATABASES = {"default": {}}
import dj_database_url import dj_database_url
db_from_env = dj_database_url.config() db_from_env = dj_database_url.config()
DATABASES['default'].update(db_from_env) DATABASES['default'].update(db_from_env)
if DEBUG and not DATABASES['default']:
DATABASES['default'] = {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(PROJECT_ROOT, "dev.db"),
}
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "localhost").split() ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "localhost").split()
CANONICAL_HOST = os.environ.get("DJANGO_CANONICAL_HOST", None) 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)
# Make this unique, and don't share it with anybody. # Make this unique, and don't share it with anybody.
SECRET_KEY = "6r&z0i#!k-thu4nv^zzx!f$fbp(&#2i5mq_^%%@ihu_qxxotl_" SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '').strip()
if (not SECRET_KEY) and DEBUG:
SECRET_KEY = 'Ae=)D4\V=OFh~C63MJHgpc&6~"p-7>^2ux3#Cr;p^!RGw9.BT}U`pi|b04TDv_NB'
TEMPLATES = [ TEMPLATES = [
{ {