File tree 4 files changed +31
-10
lines changed
4 files changed +31
-10
lines changed Original file line number Diff line number Diff line change
1
+ SECRET_KEY = abc
2
+ DEBUG = 1
3
+ ALLOWED_HOSTS = 127.0.0.1,localhost
4
+ DB_NAME = chat_data
5
+ DB_USER = postgres
6
+ DB_PASSWORD = password
7
+ DB_HOST = localhost
8
+ DB_POST = 5432
Original file line number Diff line number Diff line change 21
21
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
22
22
23
23
# SECURITY WARNING: keep the secret key used in production secret!
24
- SECRET_KEY = ' django-insecure-r-6oa@6p)#jku)f4)-t!)&g%t6h^-3r7y-tgd&k61vsc)^ex2i'
24
+ SECRET_KEY = os . environ . get ( 'SECRET_KEY' , ' django-insecure-secret-key' )
25
25
26
26
# SECURITY WARNING: don't run with debug turned on in production!
27
- DEBUG = True
28
-
29
- ALLOWED_HOSTS = []
27
+ the_debug = os .environ .get ('DEBUG' , '1' ) == '1'
28
+ if the_debug :
29
+ DEBUG = True
30
+ ALLOWED_HOSTS = []
31
+ else :
32
+ DEBUG = False
33
+ default_host = "127.0.0.1,localhost"
34
+ ALLOWED_HOSTS = os .environ .get ('ALLOWED_HOSTS' , default_host ).split (',' )
30
35
31
36
32
37
# Application definition
93
98
DATABASES = {
94
99
'default' : {
95
100
'ENGINE' : 'django.db.backends.postgresql_psycopg2' ,
96
- 'NAME' : ' chat_data' ,
97
- 'USER' : ' postgres' ,
98
- 'PASSWORD' : ' password' ,
99
- 'HOST' : ' localhost' ,
100
- 'POST' : 5432 ,
101
+ 'NAME' : os . environ . get ( 'DB_NAME' , ' chat_data') ,
102
+ 'USER' : os . environ . get ( 'DB_USER' , ' postgres') ,
103
+ 'PASSWORD' : os . environ . get ( 'DB_PASSWORD' , ' password') ,
104
+ 'HOST' : os . environ . get ( 'DB_HOST' , ' localhost') ,
105
+ 'POST' : int ( os . environ . get ( 'DB_POST' , ' 5432' )) ,
101
106
'TEST' : {
102
107
'NAME' : os .path .join (BASE_DIR , 'db_test.sqlite3' )
103
108
}
Original file line number Diff line number Diff line change 2
2
"""Django's command-line utility for administrative tasks."""
3
3
import os
4
4
import sys
5
+ import dotenv
6
+ import pathlib
5
7
6
8
7
9
def main ():
8
10
"""Run administrative tasks."""
11
+ DOT_ENV_PATH = pathlib .Path () / '.env'
12
+ if DOT_ENV_PATH .exists ():
13
+ dotenv .read_dotenv (DOT_ENV_PATH )
14
+ else :
15
+ print ("No .env found, be sure to make it!" )
9
16
os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'core.settings' )
10
17
try :
11
18
from django .core .management import execute_from_command_line
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ djangorestframework==3.13.1
6
6
Markdown == 3.3.6
7
7
django-filter == 21.1
8
8
psycopg2 == 2.9.3
9
- django-adminlte-3 == 0.1.6
9
+ django-adminlte-3 == 0.1.6
10
+ django-dotenv == 1.4.2
You can’t perform that action at this time.
0 commit comments