Allow overriding of database url
This commit is contained in:
parent
b809629184
commit
4cf7b0d499
2 changed files with 9 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import dj_database_url
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
@ -97,11 +98,16 @@ WSGI_APPLICATION = 'project.wsgi.application'
|
|||
# Database
|
||||
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
if 'DATABASE_URL' in os.environ:
|
||||
DATABASE_CONFIG = dj_database_url.config(default=os.environ['DATABASE_URL'], conn_max_age=300)
|
||||
else:
|
||||
DATABASE_CONFIG = {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
|
||||
DATABASES = {
|
||||
'default': DATABASE_CONFIG
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
coverage==4.2
|
||||
dj_database_url==0.4.1
|
||||
Django>=1.10,<1.11
|
||||
flake8==3.2.1
|
||||
honcho==0.7.1
|
||||
|
|
Reference in a new issue