File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 11
11
"""
12
12
13
13
from pathlib import Path
14
+ from dotenv import load_dotenv
15
+ import os
16
+
17
+ # load .env
18
+ load_dotenv ()
19
+
14
20
15
21
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16
22
BASE_DIR = Path (__file__ ).resolve ().parent .parent
20
26
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
21
27
22
28
# SECURITY WARNING: keep the secret key used in production secret!
23
- SECRET_KEY = ''
29
+ SECRET_KEY = os . environ . get ( 'SECRET_KEY' )
24
30
25
31
# SECURITY WARNING: don't run with debug turned on in production!
26
32
DEBUG = True
75
81
76
82
# Database
77
83
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
78
-
84
+ HOST = os .environ .get ('HOST' )
85
+ PORT = os .environ .get ('PORT' )
86
+ NAME = os .environ .get ('NAME' )
87
+ USER = os .environ .get ('USER' )
88
+ print (USER )
89
+ PASSWORD = os .environ .get ('PASSWORD' )
79
90
DATABASES = {
80
91
'default' : {
81
92
'ENGINE' : 'django.db.backends.postgresql_psycopg2' ,
82
- 'HOST' : '' ,
83
- 'PORT' : '' ,
84
- 'NAME' : '' ,
85
- 'USER' : '' ,
86
- 'PASSWORD' : '' ,
93
+ 'HOST' : HOST ,
94
+ 'PORT' : PORT ,
95
+ 'NAME' : NAME ,
96
+ 'USER' : USER ,
97
+ 'PASSWORD' : PASSWORD
87
98
}
88
99
}
89
100
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
"""Django's command-line utility for administrative tasks."""
3
3
import os
4
+ import dotenv
4
5
import sys
5
6
6
7
@@ -19,4 +20,5 @@ def main():
19
20
20
21
21
22
if __name__ == '__main__' :
23
+ dotenv .load_dotenv ()
22
24
main ()
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ s3transfer==0.6.0
13
13
six == 1.16.0
14
14
sqlparse == 0.4.2
15
15
urllib3 == 1.26.12
16
+ python-dotenv == 0.21.0
You can’t perform that action at this time.
0 commit comments