Skip to content

Instantly share code, notes, and snippets.

@phill-tornroth
Created April 29, 2011 19:23
Show Gist options
  • Save phill-tornroth/948855 to your computer and use it in GitHub Desktop.
Save phill-tornroth/948855 to your computer and use it in GitHub Desktop.
Django settings_local handler.
# For local dev purposes, allow for importing of add'l settings from
# a settings_local.py file (over-rides any already set above)
if DEBUG:
try:
from settings_local import *
except ImportError:
pass
else:
# Special treatment for symbols in settings_local that begin with 'EXTRA_'.
# Those are sequences that will be appended to the ones we've got already.
import re
import settings_local
for attr in dir(settings_local):
match = re.search('^EXTRA_(\w+)', attr)
if match:
name = match.group(1)
value = getattr(settings_local, attr)
if name in globals():
globals()[name] += value
else:
globals()[name] = value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment