Django: handling configs for multiple environments
A common way to manage settings across environments in Django is to create a local_settings.py file and then copy into it environment specific settings during deployment. Although much of our web work is done in Django now, the Rails way of managing environments is superior.
In your project, create a settings_env directory and put into it local.py, dev.py, etc files for environment specific setup.
## ^^ standard settings.py above
# Import environment specific settings
# Pull in the settings for specific environments
# It's the last argument.
env = os.environ.get('DJANGO_ENV')
if env == "production" : from settings_env.dw import *
elif env == "staging" : from settings_env.staging import *
elif env == "dev" : from settings_env.dev import *
elif env == "local" : from settings_env.local import *
else:
print "######################################################"
print " No environment specified or specified environment"
print " does not exist in /settings_env/."
print " Continuing with no settings overrides."
print " To specify an environment (e.g. production), use"
print " DJANGO_ENV=production ./manage.py runserver"
print "######################################################"
quit()
if DEBUG=True:
## ^^ settings.py for DEBUG = True below