aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/panels/template.py
diff options
context:
space:
mode:
authorRob Hudson2009-01-23 09:31:49 -0800
committerRob Hudson2009-01-23 09:31:49 -0800
commit52adaed63ed1d6255f66a0be7abb84dadcf457bb (patch)
tree54a29151a7f5693ac701ce2424015633fd2ff72f /debug_toolbar/panels/template.py
parent356c330e6032f1f858f277e35011bec991bf109e (diff)
downloaddjango-debug-toolbar-52adaed63ed1d6255f66a0be7abb84dadcf457bb.tar.bz2
Fix triggering an extra SQL query via the auth context processor.
Fixed by moving the template panel's context_processor introspection to the content method so this happens at the process_response time instead of at process_request time. Since context processors _were_ happening at the process_response end, it was triggering the query `user.get_and_delete_messages()` which was also getting triggered separately if used in templates (i.e. the admin templates) resulting in duplicate queries showing up in the toolbar.
Diffstat (limited to 'debug_toolbar/panels/template.py')
-rw-r--r--debug_toolbar/panels/template.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py
index fa85cb8..7dc7b06 100644
--- a/debug_toolbar/panels/template.py
+++ b/debug_toolbar/panels/template.py
@@ -48,11 +48,15 @@ class TemplateDebugPanel(DebugPanel):
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()]
- )
+ self.request = request
def content(self):
+ context_processors = dict(
+ [
+ ("%s.%s" % (k.__module__, k.__name__),
+ pformat(k(self.request))) for k in get_standard_processors()
+ ]
+ )
template_context = []
for i, d in enumerate(self.templates):
info = {}
@@ -73,6 +77,6 @@ class TemplateDebugPanel(DebugPanel):
context = {
'templates': template_context,
'template_dirs': [normpath(x) for x in settings.TEMPLATE_DIRS],
- 'context_processors': self.context_processors,
+ 'context_processors': context_processors,
}
return render_to_string('debug_toolbar/panels/templates.html', context)