Set DB params from .env
This commit is contained in:
parent
16a26f312c
commit
518c0d060a
1 changed files with 14 additions and 4 deletions
|
@ -100,13 +100,26 @@ TEMPLATES = [
|
||||||
WSGI_APPLICATION = 'dynamicweb2.wsgi.application'
|
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
|
# Database
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
# 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 = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'NAME': 'app',
|
'NAME': DB_NAME,
|
||||||
|
'HOST': DB_HOST,
|
||||||
|
'PASSWORD': DB_PASS,
|
||||||
|
'USER': DB_USER,
|
||||||
|
'PORT': ''
|
||||||
}
|
}
|
||||||
# 'default': {
|
# 'default': {
|
||||||
# 'ENGINE': 'django.db.backends.sqlite3',
|
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
@ -164,9 +177,6 @@ STATICFILES_FINDERS = (
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
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!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = env('SECRET_KEY')
|
SECRET_KEY = env('SECRET_KEY')
|
||||||
|
|
Loading…
Reference in a new issue