Created
May 23, 2012 03:44
-
-
Save felipe-prenholato/2773147 to your computer and use it in GitHub Desktop.
This code allows you to use modular settings for django. Add it to settings module at <project>/settings/
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
# Apps settings are loaded from own settings files. | |
# This code allow you to use a structure similar to that: | |
# project/project/settings | |
# ├── __init__.py | |
# ├── debug_toolbar_settings.py | |
# ├── django_facebook_settings.py | |
# └── settings_local.py | |
SETTINGS_ROOT = dirname(abspath(__file__)) | |
def load_settings(settings_name): | |
try: | |
execfile(path_join(SETTINGS_ROOT,'%s.py' % settings_name), globals()) | |
except (IOError, ImportError): | |
pass | |
else: | |
if DEBUG: | |
print "Loaded settings from '%s'." % settings_name | |
# load apps settings | |
for app in INSTALLED_APPS: | |
app = app.rsplit('.',1)[-1] | |
load_settings('%s_settings' % app) | |
# load local settings | |
load_settings('settings_local') | |
# load debug toolbar settings | |
if DEBUG: load_settings('debug_toolbar_settings') | |
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
DEBUG_TOOLBAR_CONFIG = { 'INTERCEPT_REDIRECTS': False } | |
MIDDLEWARE_CLASSES += ( | |
'debug_toolbar.middleware.DebugToolbarMiddleware', | |
) | |
INSTALLED_APPS += ( | |
'debug_toolbar', #http://github.com/robhudson/django-debug-toolbar | |
) | |
TEMPLATE_CONTEXT_PROCESSORS += ( | |
'django.core.context_processors.debug', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment