aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/settings.py
diff options
context:
space:
mode:
Diffstat (limited to 'pysite/settings.py')
-rw-r--r--pysite/settings.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/pysite/settings.py b/pysite/settings.py
index fc705db6..1a31d215 100644
--- a/pysite/settings.py
+++ b/pysite/settings.py
@@ -12,15 +12,28 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
import os
+import environ
+
+
+env = environ.Env(
+ DEBUG=(bool, False)
+)
+
+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+DEBUG = env('DEBUG')
+
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = os.getenv("SECRET_KEY", "+_x00w3e94##2-qm-v(5&-x_@*l3t9zlir1etu+7$@4%!it2##")
+if DEBUG:
+ SECRET_KEY = "+_x00w3e94##2-qm-v(5&-x_@*l3t9zlir1etu+7$@4%!it2##"
+else:
+ SECRET_KEY = env('SECRET_KEY')
ALLOWED_HOSTS = ["pythondiscord.com"]
@@ -80,10 +93,7 @@ WSGI_APPLICATION = "pysite.wsgi.application"
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
- "default": {
- "ENGINE": "django.db.backends.sqlite3",
- "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
- }
+ "default": env.db()
}
@@ -125,15 +135,12 @@ USE_TZ = True
STATIC_URL = "/static/"
-# Custom settings
-
-DEBUG = False
-DEFAULT_HOST = "main"
-PARENT_HOST = "pythondiscord.com"
+# django-hosts
+# https://django-hosts.readthedocs.io/en/latest/
+ROOT_HOSTCONF = "pysite.hosts"
+DEFAULT_HOST = 'main'
-if os.getenv("DEBUG") is not None: # Debug mode
- ALLOWED_HOSTS = ["pythondiscord.local"]
- DEBUG = True
+if DEBUG:
PARENT_HOST = "pythondiscord.local:8000"
-
-ROOT_HOSTCONF = "pysite.hosts"
+else:
+ PARENT_HOST = "pythondiscord.com"