From 5cc69b0998692b5728be1a1d6ffbfa3d37f6cc3f Mon Sep 17 00:00:00 2001 From: "R. Miles McCain" Date: Fri, 17 Apr 2020 11:51:27 -0400 Subject: [PATCH] Make settings more flexible with env variables --- kubernetes/secrets_template.yml | 1 + shynet/shynet/settings.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kubernetes/secrets_template.yml b/kubernetes/secrets_template.yml index 058a6f4..b698042 100644 --- a/kubernetes/secrets_template.yml +++ b/kubernetes/secrets_template.yml @@ -9,6 +9,7 @@ stringData: ALLOWED_HOSTS: "*" # For better security, set this to your deployment's domain. Comma separated. DJANGO_SECRET_KEY: "" SIGNUPS_ENABLED: "False" + TIME_ZONE: "America/New_York" # Redis configuration (if you use the default Kubernetes config, this will work) REDIS_CACHE_LOCATION: "redis://redis.default.svc.cluster.local/0" diff --git a/shynet/shynet/settings.py b/shynet/shynet/settings.py index baa58fb..a3b6f49 100644 --- a/shynet/shynet/settings.py +++ b/shynet/shynet/settings.py @@ -23,7 +23,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "q@@928+gjkhmcdpuwse0awn@#ygm#0etg11jlny+b*^cm5m-x!" +SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "onlyusethisindev") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv("DEBUG", "True") == "True" @@ -161,7 +161,7 @@ LOGGING = { LANGUAGE_CODE = "en-us" -TIME_ZONE = "America/New_York" +TIME_ZONE = os.getenv("TIME_ZONE", "America/New_York") USE_I18N = True @@ -236,7 +236,7 @@ MESSAGE_TAGS = { SERVER_EMAIL = os.getenv("SERVER_EMAIL", "Shynet ") DEFAULT_FROM_EMAIL = SERVER_EMAIL -if DEBUG: +if DEBUG or os.environ.get("EMAIL_HOST") is None: EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" else: EMAIL_HOST = os.environ.get("EMAIL_HOST")