From 6c26d39f65a66429ae1ec9a00d9676f29c408c45 Mon Sep 17 00:00:00 2001 From: "Nikita P. Shupeyko" Date: Sun, 4 Mar 2018 17:24:06 +0300 Subject: [PATCH] Unconditionally connect to database from DATABASE_URL env when opting for Docker Closes #1541. --- {{cookiecutter.project_slug}}/config/settings/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 9e16919e..9b14f5ac 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -110,9 +110,15 @@ MANAGERS = ADMINS # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases # Uses django-environ to accept uri format # See: https://django-environ.readthedocs.io/en/latest/#supported-types +{% if cookiecutter.use_docker == 'y' %} +DATABASES = { + 'default': env.db('DATABASE_URL'), +} +{% else %} DATABASES = { 'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'), } +{% endif %} DATABASES['default']['ATOMIC_REQUESTS'] = True