Petr 4 years ago
parent
commit
c15db854c1
2 changed files with 10 additions and 4 deletions
  1. 9 4
      db_prj/settings.py
  2. 1 0
      req.txt

+ 9 - 4
db_prj/settings.py

@@ -12,16 +12,21 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
 
 from pathlib import Path
 import os
+from envparse import env
 
-# Build paths inside the project like this: BASE_DIR / 'subdir'.
-BASE_DIR = Path(__file__).resolve().parent.parent
+env.read_envfile('.env')
 
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
 # Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
 
 # SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = 'x_%_ue!xjmxaer!j&3@_lhcdz44jx+g#qmjiasz27nh^wqv)$&'
+SECRET_KEY = os.environ['SECRET_KEY']
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = bool(int(os.environ['DEBUG']))
 
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True

+ 1 - 0
req.txt

@@ -4,3 +4,4 @@ Django==3.1.4
 pytz==2020.4
 soft-delete==0.2.2
 sqlparse==0.4.1
+envparse