Created
September 14, 2009 17:30
-
-
Save washingtontimes/186787 to your computer and use it in GitHub Desktop.
Django app auto-import
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 importlib, os | |
APP_DIRS = (os.path.abspath(os.path.join(PROJECT_ROOT, 'test')),) | |
sys.path.extend(APP_DIRS) | |
BASE_URL_CONFS = [] | |
for app_dir in APP_DIRS: | |
for app in os.listdir(app_dir): | |
if not app.startswith('.') and app not in INSTALLED_APPS: | |
try: | |
app_settings = importlib.import_module('%s.settings' % app) | |
if getattr(app_settings, 'APP_NAME', '') != '': | |
print "Auto Installed %s" % app | |
INSTALLED_APPS = INSTALLED_APPS + (app,) | |
base_url_conf = getattr(app_settings, 'BASE_URL_CONF', '') | |
if base_url_conf != '': | |
BASE_URL_CONFS.append(base_url_conf) | |
except ImportError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment