Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Django app auto-import
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