Skip to content

Commit 9067568

Browse files
committed
Merge pull request #213 from thinred/master
Refactored template filtering: discard DjDT templates asap.
2 parents 46f71cc + 9fdf67a commit 9067568

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

debug_toolbar/panels/template.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def __init__(self, *args, **kwargs):
5151
template_rendered.connect(self._store_template_info)
5252

5353
def _store_template_info(self, sender, **kwargs):
54+
t = kwargs['template']
55+
if t.name and t.name.startswith('debug_toolbar/'):
56+
return # skip templates that we are generating through the debug toolbar.
5457
context_data = kwargs['context']
5558

5659
context_list = []
@@ -95,8 +98,7 @@ def nav_title(self):
9598
return _('Templates')
9699

97100
def title(self):
98-
num_templates = len([t for t in self.templates
99-
if not (t['template'].name and t['template'].name.startswith('debug_toolbar/'))])
101+
num_templates = len(self.templates)
100102
return _('Templates (%(num_templates)s rendered)') % {'num_templates': num_templates}
101103

102104
def url(self):
@@ -117,9 +119,6 @@ def process_response(self, request, response):
117119
info = {}
118120
# Clean up some info about templates
119121
template = template_data.get('template', None)
120-
# Skip templates that we are generating through the debug toolbar.
121-
if template.name and template.name.startswith('debug_toolbar/'):
122-
continue
123122
if not hasattr(template, 'origin'):
124123
continue
125124
if template.origin and template.origin.name:

0 commit comments

Comments
 (0)