1
Fork 0

Allow overriding of database url

This commit is contained in:
Jake Howard 2016-11-26 13:17:38 +00:00
parent b809629184
commit 4cf7b0d499
2 changed files with 9 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import os import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -97,11 +98,16 @@ WSGI_APPLICATION = 'project.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases # https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = { if 'DATABASE_URL' in os.environ:
'default': { DATABASE_CONFIG = dj_database_url.config(default=os.environ['DATABASE_URL'], conn_max_age=300)
else:
DATABASE_CONFIG = {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
} }
DATABASES = {
'default': DATABASE_CONFIG
} }

View file

@ -1,4 +1,5 @@
coverage==4.2 coverage==4.2
dj_database_url==0.4.1
Django>=1.10,<1.11 Django>=1.10,<1.11
flake8==3.2.1 flake8==3.2.1
honcho==0.7.1 honcho==0.7.1