Skip to content

Instantly share code, notes, and snippets.

@chriskief
Created October 24, 2013 02:38
Show Gist options
  • Save chriskief/7130391 to your computer and use it in GitHub Desktop.
Save chriskief/7130391 to your computer and use it in GitHub Desktop.
HOST_IP_ADDRESS = socket.gethostbyname(socket.gethostname())
HOST_NAME = socket.gethostname()
if string.find(HOST_NAME, '.local') is not -1:
DJANGO_CONF = 'dev'
elif HOST_IP_ADDRESS is '123.123.123.123':
DJANGO_CONF = 'staging'
else:
DJANGO_CONF = 'prod'
# import from the selected environment (i.e. environments.dev)
module = __import__('environments.' + DJANGO_CONF, globals(), locals(), ['*'])
for k in dir(module):
locals()[k] = getattr(module, k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment