diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 3bf3a73ccb..9ab67bde25 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -44,16 +44,28 @@ # DATABASES # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#databases -{% 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 %} +try: + {%- 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 %} +except environ.ImproperlyConfigured: + DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": env.str("POSTGRES_DB"), + "USER": env.str("POSTGRES_USER"), + "PASSWORD": env.str("POSTGRES_PASSWORD"), + "HOST": env.str("POSTGRES_HOST"), + "PORT": env.str("POSTGRES_PORT"), + } + } DATABASES["default"]["ATOMIC_REQUESTS"] = True # https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-DEFAULT_AUTO_FIELD DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" @@ -285,7 +297,11 @@ # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone CELERY_TIMEZONE = TIME_ZONE # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url -CELERY_BROKER_URL = env("CELERY_BROKER_URL") +try: + CELERY_BROKER_URL = env("CELERY_BROKER_URL") +except environ.ImproperlyConfigured: + CELERY_BROKER_URL = env("REDIS_URL") + # https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend CELERY_RESULT_BACKEND = CELERY_BROKER_URL # https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended