Simple settings in Django
Background
As I beef up my Django skill set, I have been playing with different deploy options. At the moment, I'd rather use a PaaS than roll my own server and have to manage security and updates. Like many people, I love Heroku. This is a (very) simple method to change settings between a local and production environment.
Code
settings.py
import os
...
if os.environ.get('PRODUCTION', False): # check if $PRODUCTION is True
# Production server configurations go here
...
else:
# Development server configurations go here
....
Clean and super easy.
Supplemental notes
This configuration is not Heroku specific. If you are running your own server, you can simply add an environment variable using the following.
export PRODUCTION=True
Written by Keith
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Heroku
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#