Skip to content

Instantly share code, notes, and snippets.

Created February 13, 2009 12:38
Show Gist options
  • Save anonymous/63878 to your computer and use it in GitHub Desktop.
Save anonymous/63878 to your computer and use it in GitHub Desktop.
import os
def import_all_from(module_name, globals_):
# Calling it with the globals_ module provides a hook into the
# module-level globals; otherwise we'd get the function's globals
# (which might be different).
module_split = module_name.split('.')
module = __import__(module_name, module_name.split('.')[:-1])
for attr in dir(module):
if not (attr.startswith('__') and attr.endswith('__')):
globals_[attr] = getattr(module, attr)
SETTINGS_MODE = os.environ.get('DJANGO_SETTINGS_MODE', None)
import_all_from(__name__ + '.common', globals())
if SETTINGS_MODE:
import_all_from(__name__ + '.' + SETTING_MODE.lower(), globals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment