1 2 3 4 5 6 7 8 9 10 11 12 13 | import os
import os.path
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
local_import = "env/development.py"
if os.getenv("DJANGO_ENV") == 'TEST':
local_import = "env/test.py"
elif os.getenv("DJANGO_ENV") == 'PRODUCTION':
local_import = "env/production.py"
import_file = open(os.path.join(PROJECT_ROOT, local_import))
exec(import_file)
|
More like this
- Load a local settings file for dev/test environments by menendez 3 years, 6 months ago
- Seamless Django and VirtualEnv integration by kmmbvnr 1 year, 4 months ago
- integrated jinja2 which could use generic view ,my djangojinja2.py by jasongreen 2 years, 1 month ago
- monkey-patch django to use jinja2 templates for 404/500 pages and 3rd-party apps by brondsem 2 years, 11 months ago
- Keep settings.py in version control safely by mboersma 4 years, 11 months ago
Comments
That's cool and see why someone might want to do this; but I find it simpler to duplicate my settings.py file rename it to local_settings.py (or whatever you like) and add the following to the end of the original settings.py:
#