Last Updated: February 25, 2016
· keithio

Simple settings in Django


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.


import os
if os.environ.get('PRODUCTION', False):  # check if $PRODUCTION is True
    # Production server configurations go here
    # 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