-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_settings.py
33 lines (26 loc) · 959 Bytes
/
my_settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os, json
from django.core.exceptions import ImproperlyConfigured
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Below path would be different for each hardware
secret_file = os.path.join(BASE_DIR, 'TheSignature/secrets.json')
with open(secret_file) as f:
secrets = json.loads(f.read())
def get_secret(key, secrets=secrets):
try:
return secrets[key]
except KeyError:
error_msg = "Set the {} environment variable".format(key)
raise ImproperlyConfigured(error_msg)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': get_secret("DB_NAME"),
'USER': get_secret("DB_USER"),
'PASSWORD': get_secret("DB_PASSWD"),
'HOST': '',
'PORT': get_secret("DB_PORT")
}
}
SECRET_KEY = get_secret("SECRET_KEY")
#Handle session is not Json Serializable
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'