diff options
Diffstat (limited to 'debug_toolbar/toolbar/loader.py')
| -rw-r--r-- | debug_toolbar/toolbar/loader.py | 11 |
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: |
