· 6 years ago · Jun 17, 2019, 02:00 PM
1env = environ.Env(
2 DEBUG=(bool, False),
3 SECRET_KEY=(str, ''),
4 DATABASE_URL=(str, 'postgres://testing:testing@localhost/testing'),
5)
6if os.path.exists(env_file):
7 env.read_env(env_file)
8
9DEBUG = env.bool('DEBUG')
10SECRET_KEY = env.str('SECRET_KEY')
11if DEBUG and not SECRET_KEY:
12 SECRET_KEY = 'xxx'
13
14# Default '@localhost' is needed for the production server. But that will probably fail
15# on development machine. Write "DEBUG=1" to ".env" file to enable.
16if DEBUG:
17 DATABASE_URL = 'postgres://testing:testing@testing_postgres/testing'
18
19DATABASES = {'default': env.db()}