From 78bceaad8c12522818807df374d0937af860e8f5 Mon Sep 17 00:00:00 2001 From: Nico Virkki Date: Mon, 14 Oct 2024 11:24:18 +0300 Subject: [PATCH] chore(db-con): use database password if present in env Use the DATABASE_PASSWORD environment variable if it exists and use it in database connection. This is the way. Refs RATY-129 --- open_city_profile/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/open_city_profile/settings.py b/open_city_profile/settings.py index 8786baf4..71968610 100644 --- a/open_city_profile/settings.py +++ b/open_city_profile/settings.py @@ -32,6 +32,7 @@ str, "postgres://open_city_profile:open_city_profile@localhost/open_city_profile", ), + DATABASE_PASSWORD=(str, ""), CACHE_URL=(str, "locmemcache://"), EMAIL_URL=(str, "consolemail://"), SENTRY_DSN=(str, ""), @@ -136,6 +137,9 @@ # Ensure postgis engine DATABASES["default"]["ENGINE"] = "django.contrib.gis.db.backends.postgis" +if env("DATABASE_PASSWORD"): + DATABASES["default"]["PASSWORD"] = env("DATABASE_PASSWORD") + CACHES = {"default": env.cache()} vars().update(env.email_url()) # EMAIL_BACKEND etc.