Skip to content

Instantly share code, notes, and snippets.

@jmg
Created May 16, 2014 20:49
Show Gist options
  • Save jmg/4760d7cc6586fe7d8c0b to your computer and use it in GitHub Desktop.
Save jmg/4760d7cc6586fe7d8c0b to your computer and use it in GitHub Desktop.
Configuration for multiple environments in manage.py
import os
# By default assume it's local environment
env = os.environ.get("ENV", "LOCAL")
# PROD/DEV/LOCAL are values the environment variable ENV can have.
# Example for production server: ~$ export ENV=PROD
settings_files = {
"PROD": "production_settings",
"DEV": "development_settings",
"LOCAL": "local_settings",
}
settings_file = settings_files.get(env)
try
settings = __import__(settings_file, globals(), locals()) # Assumed to be in the same directory.
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment