aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.rst4
-rw-r--r--debug_toolbar/middleware.py13
2 files changed, 16 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index 479d4c0..492c8f7 100644
--- a/README.rst
+++ b/README.rst
@@ -114,6 +114,9 @@ The debug toolbar has two settings that can be set in `settings.py`:
off is useful when you have large template contexts, or you have template
contexts with lazy datastructures that you don't want to be evaluated.
+ * `TAG`: If set, this will be the tag to which debug_toolbar will attach the
+ debug toolbar. Defaults to 'body'.
+
Example configuration::
def custom_show_toolbar(request):
@@ -124,6 +127,7 @@ The debug toolbar has two settings that can be set in `settings.py`:
'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
'HIDE_DJANGO_SQL': False,
+ 'TAG': 'div',
}
`debugsqlshell`
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index 558019c..86f13cb 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -37,12 +37,20 @@ class DebugToolbarMiddleware(object):
# Set method to use to decide to show toolbar
self.show_toolbar = self._show_toolbar # default
+
+ # The tag to attach the toolbar to
+ self.tag= u'</body>'
+
if hasattr(settings, 'DEBUG_TOOLBAR_CONFIG'):
show_toolbar_callback = settings.DEBUG_TOOLBAR_CONFIG.get(
'SHOW_TOOLBAR_CALLBACK', None)
if show_toolbar_callback:
self.show_toolbar = show_toolbar_callback
+ tag = settings.DEBUG_TOOLBAR_CONFIG.get('TAG', None)
+ if tag:
+ self.tag = u'</' + tag + u'>'
+
def _show_toolbar(self, request):
if not request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS \
or request.is_ajax() or not settings.DEBUG:
@@ -83,6 +91,9 @@ class DebugToolbarMiddleware(object):
for panel in self.debug_toolbars[request].panels:
panel.process_response(request, response)
if response['Content-Type'].split(';')[0] in _HTML_TYPES:
- response.content = replace_insensitive(smart_unicode(response.content), u'</body>', smart_unicode(self.debug_toolbars[request].render_toolbar() + u'</body>'))
+ response.content = replace_insensitive(
+ smart_unicode(response.content),
+ self.tag,
+ smart_unicode(self.debug_toolbars[request].render_toolbar() + self.tag))
del self.debug_toolbars[request]
return response