Created
February 13, 2009 12:38
-
-
Save anonymous/63878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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