Skip to content

Commit cb0315f

Browse files
author
AhmadMWaddah
committed
Fix: Add guard against literal DATABASE_URL string
1 parent 506c397 commit cb0315f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

config/settings/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@
103103
# See dev.py and prod.py for environment-specific database settings.
104104

105105
# Support DATABASE_URL (Render) or individual DB_* vars
106-
db_url = os.getenv("DATABASE_URL", "").strip()
107-
if db_url and "//" in db_url and "postgres" in db_url:
106+
db_url = os.getenv("DATABASE_URL", "")
107+
# Validate: must contain :// and postgres, NOT be literal "DATABASE_URL"
108+
if db_url and "://" in db_url and "postgres" in db_url and db_url != "DATABASE_URL":
108109
# Use DATABASE_URL from Render
109110
DATABASES = {"default": env.db_url_config("DATABASE_URL")}
110111
else:

0 commit comments

Comments
 (0)