aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/toolbar
diff options
context:
space:
mode:
authorJannis Leidel2010-02-16 22:40:25 +0100
committerRob Hudson2010-02-16 15:40:07 -0800
commit3bfcb1d76ad08146958038455450369bd3ea4e07 (patch)
treef9ebf00bdcc7d35037de253d7afd05decd073e5d /debug_toolbar/toolbar
parent25e96145cfb28079718c89f9e24bc0c7effd1d9d (diff)
downloaddjango-debug-toolbar-3bfcb1d76ad08146958038455450369bd3ea4e07.tar.bz2
Fixed #60 - Added MEDIA_URL config option to be able to override the URL to the static files (good with django-staticfiles). Also moved media files to subdirectories like other apps.
Signed-off-by: Rob Hudson <rob@cogit8.org>
Diffstat (limited to 'debug_toolbar/toolbar')
-rw-r--r--debug_toolbar/toolbar/loader.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py
index 8e89aef..4b53d2f 100644
--- a/debug_toolbar/toolbar/loader.py
+++ b/debug_toolbar/toolbar/loader.py
@@ -1,6 +1,7 @@
"""
The main DebugToolbar class that loads and renders the Toolbar.
"""
+from django.conf import settings
from django.template.loader import render_to_string
class DebugToolbar(object):
@@ -8,11 +9,16 @@ class DebugToolbar(object):
def __init__(self, request):
self.request = request
self.panels = []
+ base_url = self.request.META.get('SCRIPT_NAME', '')
self.config = {
'INTERCEPT_REDIRECTS': True,
+ 'MEDIA_URL': u'%s/__debug__/m/' % base_url
}
+ # Check if settings has a DEBUG_TOOLBAR_CONFIG and updated config
+ self.config.update(getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}))
self.template_context = {
- 'BASE_URL': self.request.META.get('SCRIPT_NAME', ''),
+ 'BASE_URL': base_url, # for backwards compatibility
+ 'DEBUG_TOOLBAR_MEDIA_URL': self.config.get('MEDIA_URL'),
}
# Override this tuple by copying to settings.py as `DEBUG_TOOLBAR_PANELS`
self.default_panels = (
@@ -39,9 +45,6 @@ class DebugToolbar(object):
# Check if settings has a DEBUG_TOOLBAR_PANELS, otherwise use default
if hasattr(settings, 'DEBUG_TOOLBAR_PANELS'):
self.default_panels = settings.DEBUG_TOOLBAR_PANELS
- # Check if settings has a DEBUG_TOOLBAR_CONFIG and updated config
- if hasattr(settings, 'DEBUG_TOOLBAR_CONFIG'):
- self.config.update(settings.DEBUG_TOOLBAR_CONFIG)
for panel_path in self.default_panels:
try: