aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Scardine2013-05-23 22:50:33 -0300
committerAymeric Augustin2013-10-27 10:24:39 +0100
commitc710140a15222af2cf31b7579c6a5fedf9a482d5 (patch)
tree5ec0c8f997aacdbf24d5d77686f619362d6f5107
parentae52695631b409420aa1cf703a94a80c28c652b7 (diff)
downloaddjango-debug-toolbar-c710140a15222af2cf31b7579c6a5fedf9a482d5.tar.bz2
Allow setting arbitrary attributes on the toolbar.
Fix #334.
-rw-r--r--README.rst6
-rw-r--r--debug_toolbar/templates/debug_toolbar/base.html2
-rw-r--r--debug_toolbar/toolbar/loader.py4
3 files changed, 10 insertions, 2 deletions
diff --git a/README.rst b/README.rst
index 2ada325..6635837 100644
--- a/README.rst
+++ b/README.rst
@@ -180,6 +180,12 @@ The debug toolbar has two settings that can be set in ``settings.py``:
(The first value is ``socketserver`` on Python 3 and ``SocketServer`` on
Python 2.)
+ * ``ROOT_TAG_ATTRS``
+
+ This setting is injected in the root template div in order to avoid conflicts
+ with client-side frameworks. For example, when using with Angular.js, set
+ this to 'ng-non-bindable' or 'class="ng-non-bindable"'. Defaults to ''.
+
Example configuration::
def custom_show_toolbar(request):
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index 7b42c84..cce2144 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -4,7 +4,7 @@
</style>
<link rel="stylesheet" href="{{ STATIC_URL }}debug_toolbar/css/toolbar.min.css" type="text/css" />
<script type="text/javascript" src="{{ STATIC_URL }}debug_toolbar/js/toolbar.min.js"></script>
-<div id="djDebug" style="display:none;" dir="ltr">
+<div id="djDebug" style="display:none;" dir="ltr" {{ TOOLBAR_ROOT_TAG_ATTRS|safe }}>
<div style="display:none;" id="djDebugToolbar">
<ul id="djDebugPanelList">
{% if panels %}
diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py
index 5b55149..491f66c 100644
--- a/debug_toolbar/toolbar/loader.py
+++ b/debug_toolbar/toolbar/loader.py
@@ -18,7 +18,8 @@ class DebugToolbar(object):
base_url = self.request.META.get('SCRIPT_NAME', '')
self.config = {
'INTERCEPT_REDIRECTS': False,
- 'MEDIA_URL': '%s/__debug__/m/' % base_url
+ 'MEDIA_URL': '%s/__debug__/m/' % base_url,
+ 'ROOT_TAG_ATTRS': '',
}
# Check if settings has a DEBUG_TOOLBAR_CONFIG and updated config
self.config.update(getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}))
@@ -26,6 +27,7 @@ class DebugToolbar(object):
'BASE_URL': base_url, # for backwards compatibility
'DEBUG_TOOLBAR_MEDIA_URL': self.config.get('MEDIA_URL'),
'STATIC_URL': settings.STATIC_URL,
+ 'TOOLBAR_ROOT_TAG_ATTRS': self.config.get('ROOT_TAG_ATTRS'),
}
self.load_panels()