File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+ from dotenv import load_dotenv
3+
4+ load_dotenv ()
5+
6+ POSTGRES_USER = os .getenv ("POSTGRES_USER" , "postgres" )
7+ POSTGRES_PASSWORD = os .getenv ("POSTGRES_PASSWORD" , "" )
8+ POSTGRES_DB = os .getenv ("POSTGRES_DB" , "postgres" )
9+ DB_HOST = os .getenv ("DB_HOST" , "127.0.0.1" )
10+ DB_PORT = os .getenv ("DB_PORT" , "5432" )
11+
12+ DJANGO_SECRET_KEY = os .getenv ("DJANGO_SECRET_KEY" , "fallback-secret" )
13+ DJANGO_DEBUG = os .getenv ("DJANGO_DEBUG" , "False" ) == "True"
14+ DJANGO_ALLOWED_HOSTS = os .getenv ("DJANGO_ALLOWED_HOSTS" , "localhost" ).split ("," )
Original file line number Diff line number Diff line change 1- # flake8: noqa
21import os
32from pathlib import Path
43
4+ from config import (
5+ POSTGRES_USER ,
6+ POSTGRES_PASSWORD ,
7+ POSTGRES_DB ,
8+ DB_HOST ,
9+ DB_PORT ,
10+ DJANGO_SECRET_KEY ,
11+ DJANGO_DEBUG ,
12+ DJANGO_ALLOWED_HOSTS ,
13+ )
14+
515BASE_DIR = Path (__file__ ).resolve ().parent .parent
616
7- SECRET_KEY = os . getenv ( ' DJANGO_SECRET_KEY' )
17+ SECRET_KEY = DJANGO_SECRET_KEY
818
9- DEBUG = os . getenv ( ' DJANGO_DEBUG' , 'false' ). lower () == 'true'
19+ DEBUG = DJANGO_DEBUG
1020
11- ALLOWED_HOSTS = os . getenv ( ' DJANGO_ALLOWED_HOSTS' , 'localhost' ). split ( ',' )
21+ ALLOWED_HOSTS = DJANGO_ALLOWED_HOSTS
1222
1323INSTALLED_APPS = [
1424 'django.contrib.admin' ,
5666DATABASES = {
5767 'default' : {
5868 'ENGINE' : 'django.db.backends.postgresql' ,
59- 'NAME' : os . getenv ( ' POSTGRES_DB' , 'django' ) ,
60- 'USER' : os . getenv ( ' POSTGRES_USER' , 'django' ) ,
61- 'PASSWORD' : os . getenv ( ' POSTGRES_PASSWORD' , '' ) ,
62- 'HOST' : os . getenv ( ' DB_HOST' , '' ) ,
63- 'PORT' : os . getenv ( ' DB_PORT' , 5432 )
69+ 'NAME' : POSTGRES_DB ,
70+ 'USER' : POSTGRES_USER ,
71+ 'PASSWORD' : POSTGRES_PASSWORD ,
72+ 'HOST' : DB_HOST ,
73+ 'PORT' : DB_PORT
6474 }
6575}
6676
You can’t perform that action at this time.
0 commit comments