Skip to content

Commit

Permalink
add defaults since it breaks the build
Browse files Browse the repository at this point in the history
  • Loading branch information
Anish9901 committed Nov 12, 2024
1 parent c5fc577 commit 5e02bee
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions config/settings/common_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ def pipe_delim(pipe_string):
}

# POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_HOST & POSTGRES_PORT are required env variables for forming a pg connection string for the django database
POSTGRES_DB = os.environ['POSTGRES_DB']
POSTGRES_USER = os.environ['POSTGRES_USER']
POSTGRES_PASSWORD = os.environ['POSTGRES_PASSWORD']
POSTGRES_HOST = os.environ['POSTGRES_HOST']
POSTGRES_PORT = os.environ['POSTGRES_PORT']

DATABASES['default'] = db_url(f'postgres://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}')
POSTGRES_DB = os.environ.get('POSTGRES_DB', default=None)
POSTGRES_USER = os.environ.get('POSTGRES_USER', default=None)
POSTGRES_PASSWORD = os.environ.get('POSTGRES_PASSWORD', default=None)
POSTGRES_HOST = os.environ.get('POSTGRES_HOST', default=None)
POSTGRES_PORT = os.environ.get('POSTGRES_PORT', default=None)

if POSTGRES_DB and POSTGRES_USER and POSTGRES_PASSWORD and POSTGRES_HOST and POSTGRES_PORT:
DATABASES['default'] = db_url(f'postgres://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}')

for db_key, db_dict in DATABASES.items():
# Engine should be '.postgresql' or '.postgresql_psycopg2' for all db(s)
Expand Down

0 comments on commit 5e02bee

Please sign in to comment.