aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Leidel2008-09-24 12:40:02 +0200
committerJannis Leidel2008-09-24 12:40:02 +0200
commitd74431411b5c390379bcac89a60628a26365d8c9 (patch)
tree32969f694832244a68b4b7da4d9b9af3991798be
parent39ceacf7c90a984efe21d3d67d30767ffcb97497 (diff)
downloaddjango-debug-toolbar-d74431411b5c390379bcac89a60628a26365d8c9.tar.bz2
Added context processors to TemplateDebugPanel
-rw-r--r--debug_toolbar/panels/template.py7
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/templates.html14
2 files changed, 21 insertions, 0 deletions
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py
index eb20079..9cab618 100644
--- a/debug_toolbar/panels/template.py
+++ b/debug_toolbar/panels/template.py
@@ -4,6 +4,7 @@ from django.core.signals import request_started
from django.dispatch import Signal
from django.template.loader import render_to_string
from django.test.signals import template_rendered
+from django.template.context import get_standard_processors
from debug_toolbar.panels import DebugPanel
# Code taken and adapted from Simon Willison and Django Snippets:
@@ -44,6 +45,11 @@ class TemplateDebugPanel(DebugPanel):
def url(self):
return ''
+ def process_request(self, request):
+ self.context_processors = dict(
+ [("%s.%s" % (k.__module__, k.__name__), pformat(k(request))) for k in get_standard_processors()]
+ )
+
def content(self):
template_context = []
for i, d in enumerate(self.templates):
@@ -65,5 +71,6 @@ class TemplateDebugPanel(DebugPanel):
context = {
'templates': template_context,
'template_dirs': settings.TEMPLATE_DIRS,
+ 'context_processors': self.context_processors,
}
return render_to_string('debug_toolbar/panels/templates.html', context)
diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html
index 575d507..e878be2 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/templates.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html
@@ -23,3 +23,17 @@
{% else %}
None
{% endif %}
+{% if context_processors %}
+<h3>Context processors used:</h3>
+<dl>
+{% for key, value in context_processors.iteritems %}
+ <dt><strong>{{ key|escape }}</strong></dt>
+ <dd>
+ <div class="djTemplateShowContextDiv"><a class="djTemplateShowContext">Toggle Context</a></div>
+ <div class="djTemplateHideContextDiv" style="display:none;"><pre>{{ value|escape }}</pre></div>
+ </dd>
+{% endfor %}
+</dl>
+{% else %}
+ None
+{% endif %}