From f3107577646fe9ff9d6cc5b8d18dd945b6765fea Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Mon, 28 Jul 2014 19:09:07 -0400 Subject: [PATCH] Can't add secrets.py to heroku so environ instead --- laundry/settings.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/laundry/settings.py b/laundry/settings.py index 0273b21..899e58f 100644 --- a/laundry/settings.py +++ b/laundry/settings.py @@ -14,16 +14,27 @@ MANAGERS = ADMINS PROJECT_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': secrets.DATABASE_NAME, - 'USER': secrets.DATABASE_USER, - 'PASSWORD': secrets.DATABASE_PASSWORD, - 'HOST': secrets.DATABASE_HOST, - 'PORT': '', # Set to empty string for default. Not used with sqlite3. +if os.environ.get('DJANGO_ENV', None) == 'heroku': + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': os.environ.get('DJANGO_DATABASE_NAME'), + 'USER': os.environ.get('DJANGO_DATABASE_USER'), + 'PASSWORD': os.environ.get('DJANGO_DATABASE_PASSWORD'), + 'HOST': os.environ.get('DJANGO_DATABASE_HOST'), + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': secrets.DATABASE_NAME, + 'USER': secrets.DATABASE_USER, + 'PASSWORD': secrets.DATABASE_PASSWORD, + 'HOST': secrets.DATABASE_HOST, + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } } -} # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts