Commit defa1e5f authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

Add dotenv to esi

parent 934e71b1
...@@ -11,6 +11,17 @@ https://docs.djangoproject.com/en/1.11/ref/settings/ ...@@ -11,6 +11,17 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
import os import os
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
def get_env(name):
return os.environ[name]
def get_bool_env(name):
return True if os.environ[name] == 'True' else False
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...@@ -20,10 +31,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ...@@ -20,10 +31,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*%!eg7znv=2z5cak1fjt#6-org#i@pe%uy7vkks$&3otoupb8x' SECRET_KEY = get_env('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = get_bool_env('DEBUG')
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
...@@ -92,8 +103,8 @@ DATABASES = { ...@@ -92,8 +103,8 @@ DATABASES = {
'esi': { 'esi': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': 'esi', 'NAME': 'esi',
'USER': 'root', 'USER': get_env('DB_USER'),
'PASSWORD': 'Q!W@q1w2mysql', 'PASSWORD': get_env('DB_PASSWORD'),
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '3306', 'PORT': '3306',
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment