diff --git a/dynamicweb2/settings.py b/dynamicweb2/settings.py index 32dfb9f..d909def 100644 --- a/dynamicweb2/settings.py +++ b/dynamicweb2/settings.py @@ -100,13 +100,26 @@ TEMPLATES = [ WSGI_APPLICATION = 'dynamicweb2.wsgi.application' +def env(env_name): + env_name = os.environ.get(env_name) + return env_name if env_name else '0' + # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases +DB_USER=env('POSTGRES_USER') +DB_PASS=env('POSTGRES_PASSWORD') +DB_HOST=env('POSTGRES_HOST') +DB_NAME=env('POSTGRES_DB') + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'app', + 'NAME': DB_NAME, + 'HOST': DB_HOST, + 'PASSWORD': DB_PASS, + 'USER': DB_USER, + 'PORT': '' } # 'default': { # 'ENGINE': 'django.db.backends.sqlite3', @@ -164,9 +177,6 @@ STATICFILES_FINDERS = ( DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -def env(env_name): - return os.environ.get(env_name) - # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = env('SECRET_KEY')