Fix database config
This commit is contained in:
parent
83a388343b
commit
fcf0ccde53
3 changed files with 28 additions and 9 deletions
|
@ -173,8 +173,16 @@
|
|||
"value": "${DJANGO_SECRET_KEY}"
|
||||
},
|
||||
{
|
||||
"name": "DATABASE_URL",
|
||||
"value": "postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@$DATABASE_SERVICE_HOST:$DATABASE_SERVICE_PORT/${DATABASE_NAME}"
|
||||
"name": "DATABASE_USER",
|
||||
"value": "${DATABASE_USER}"
|
||||
},
|
||||
{
|
||||
"name": "DATABASE_PASSWORD",
|
||||
"value": "${DATABASE_PASSWORD}"
|
||||
},
|
||||
{
|
||||
"name": "DATABASE_NAME",
|
||||
"value": "${DATABASE_NAME}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
|
|||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
import dj_database_url
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
@ -80,11 +79,24 @@ WSGI_APPLICATION = 'project.wsgi.application'
|
|||
# Database
|
||||
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': dj_database_url.config(
|
||||
default='sqlite:///'+os.path.join(BASE_DIR, 'db.sqlite3')
|
||||
)
|
||||
}
|
||||
if os.getenv("DATABASE_SERVICE_HOST"):
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': os.getenv("DATABASE_NAME"),
|
||||
'USER': os.getenv("DATABASE_USER"),
|
||||
'PASSWORD': os.getenv("DATABASE_PASSWORD"),
|
||||
'HOST': os.getenv("DATABASE_SERVICE_HOST"),
|
||||
'PORT': os.getenv("DATABASE_SERVICE_PORT"),
|
||||
}
|
||||
}
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Internationalization
|
||||
|
|
|
@ -2,4 +2,3 @@ Django==1.8.1
|
|||
psycopg2==2.6
|
||||
gunicorn==19.3.0
|
||||
whitenoise==1.0.6
|
||||
dj-database-url==0.3.0
|
||||
|
|
Loading…
Reference in a new issue