Skip to content

Commit 37e6fbb

Browse files
committed
[chore] secret key 및 RDS key 값을 환경변수로 추가
1 parent 9a91189 commit 37e6fbb

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

backend/settings.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"""
1212

1313
from pathlib import Path
14+
from dotenv import load_dotenv
15+
import os
16+
17+
# load .env
18+
load_dotenv()
19+
1420

1521
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1622
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -20,7 +26,7 @@
2026
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
2127

2228
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = ''
29+
SECRET_KEY = os.environ.get('SECRET_KEY')
2430

2531
# SECURITY WARNING: don't run with debug turned on in production!
2632
DEBUG = True
@@ -75,15 +81,20 @@
7581

7682
# Database
7783
# 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')
7990
DATABASES = {
8091
'default': {
8192
'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
8798
}
8899
}
89100

manage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
"""Django's command-line utility for administrative tasks."""
33
import os
4+
import dotenv
45
import sys
56

67

@@ -19,4 +20,5 @@ def main():
1920

2021

2122
if __name__ == '__main__':
23+
dotenv.load_dotenv()
2224
main()

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ s3transfer==0.6.0
1313
six==1.16.0
1414
sqlparse==0.4.2
1515
urllib3==1.26.12
16+
python-dotenv==0.21.0

0 commit comments

Comments
 (0)