diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index 5c20fcd86..e5be91e0e 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -51,6 +51,9 @@ def __init__(self, *args, **kwargs): template_rendered.connect(self._store_template_info) def _store_template_info(self, sender, **kwargs): + t = kwargs['template'] + if t.name and t.name.startswith('debug_toolbar/'): + return # skip templates that we are generating through the debug toolbar. context_data = kwargs['context'] context_list = [] @@ -95,8 +98,7 @@ def nav_title(self): return _('Templates') def title(self): - num_templates = len([t for t in self.templates - if not (t['template'].name and t['template'].name.startswith('debug_toolbar/'))]) + num_templates = len(self.templates) return _('Templates (%(num_templates)s rendered)') % {'num_templates': num_templates} def url(self): @@ -117,9 +119,6 @@ def process_response(self, request, response): info = {} # Clean up some info about templates template = template_data.get('template', None) - # Skip templates that we are generating through the debug toolbar. - if template.name and template.name.startswith('debug_toolbar/'): - continue if not hasattr(template, 'origin'): continue if template.origin and template.origin.name: