mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-29 21:14:03 +03:00
load .env file if DJANGO_READ_DOT_ENV_FILE is True
This commit is contained in:
parent
a542a7e51c
commit
2af079f7aa
|
@ -16,7 +16,21 @@ ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config
|
||||||
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
|
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
|
||||||
|
|
||||||
env = environ.Env()
|
env = environ.Env()
|
||||||
env.read_env()
|
|
||||||
|
# Load operating system environment variables and then prepare to use them
|
||||||
|
env = environ.Env()
|
||||||
|
|
||||||
|
# .env file, should load only in development environment
|
||||||
|
READ_DOT_ENV_FILE = env('DJANGO_READ_DOT_ENV_FILE', default=False)
|
||||||
|
|
||||||
|
if READ_DOT_ENV_FILE:
|
||||||
|
# Operating System Environment variables have precende over variables defined in the .env file,
|
||||||
|
# that is to say variables from the .env files will only be used if not defined
|
||||||
|
# as environment variables.
|
||||||
|
env_file = str(ROOT_DIR.path('.env'))
|
||||||
|
print('Loading : {}'.format(env_file))
|
||||||
|
env.read_env(env_file)
|
||||||
|
print('The .env file has been loaded. See common.py for more information')
|
||||||
|
|
||||||
# APP CONFIGURATION
|
# APP CONFIGURATION
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user