aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/panels/template.py19
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/templates.html10
2 files changed, 16 insertions, 13 deletions
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py
index ad6dd04..e99b9c5 100644
--- a/debug_toolbar/panels/template.py
+++ b/debug_toolbar/panels/template.py
@@ -73,15 +73,16 @@ class TemplateDebugPanel(DebugPanel):
t.origin_name = 'No origin'
info['template'] = t
# Clean up context for better readability
- c = d.get('context', None)
-
- d_list = []
- for _d in c.dicts:
- try:
- d_list.append(pformat(d))
- except UnicodeEncodeError:
- pass
- info['context'] = '\n'.join(d_list)
+ if getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('SHOW_TEMPLATE_CONTEXT', True):
+ c = d.get('context', None)
+
+ d_list = []
+ for _d in c.dicts:
+ try:
+ d_list.append(pformat(d))
+ except UnicodeEncodeError:
+ pass
+ info['context'] = '\n'.join(d_list)
template_context.append(info)
context = {
'templates': template_context,
diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html
index 6c918b1..e54c951 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/templates.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html
@@ -14,10 +14,12 @@
{% for template in templates %}
<dt><strong><a class="remoteCall" href="/__debug__/template_source/?template={{ template.template.name }}">{{ template.template.name|addslashes }}</a></strong></dt>
<dd><samp>{{ template.template.origin_name|addslashes }}</samp></dd>
- <dd>
- <div class="djTemplateShowContextDiv"><a class="djTemplateShowContext">Toggle Context</a></div>
- <div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ template.context }}</pre></div>
- </dd>
+ {% if template.context %}
+ <dd>
+ <div class="djTemplateShowContextDiv"><a class="djTemplateShowContext">Toggle Context</a></div>
+ <div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ template.context }}</pre></div>
+ </dd>
+ {% endif %}
{% endfor %}
</dl>
{% else %}