Skip to content

Commit bb9bce5

Browse files
authored
Merge pull request #942 from matthiask/mk/skip-template-prefixes
Refs #910: Skip template-based widget templates by default
2 parents f37d7ee + a0ebcc3 commit bb9bce5

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

debug_toolbar/panels/templates/panel.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ def _store_template_info(self, sender, **kwargs):
8484
template, context = kwargs['template'], kwargs['context']
8585

8686
# Skip templates that we are generating through the debug toolbar.
87-
if (isinstance(template.name, six.string_types) and
88-
template.name.startswith('debug_toolbar/')):
87+
if (isinstance(template.name, six.string_types) and (
88+
template.name.startswith('debug_toolbar/') or
89+
template.name.startswith(
90+
tuple(self.toolbar.config['SKIP_TEMPLATE_PREFIXES'])))):
8991
return
9092

9193
context_list = []

debug_toolbar/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
),
3636
'PROFILER_MAX_DEPTH': 10,
3737
'SHOW_TEMPLATE_CONTEXT': True,
38+
'SKIP_TEMPLATE_PREFIXES': (
39+
'django/forms/widgets/',
40+
'admin/widgets/',
41+
),
3842
'SQL_WARNING_THRESHOLD': 500, # milliseconds
3943
}
4044

docs/configuration.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ Panel options
170170
template contexts, or you have template contexts with lazy datastructures
171171
that you don't want to be evaluated.
172172

173+
* ``SKIP_TEMPLATE_PREFIXES``
174+
175+
Default: ``('django/forms/widgets/', 'admin/widgets/')``
176+
177+
Panel: templates.
178+
179+
Templates starting with those strings are skipped when collecting
180+
rendered templates and contexts. Template-based form widgets are
181+
skipped by default because the panel HTML can easily grow to hundreds
182+
of megabytes with many form fields and many options.
183+
173184
* ``SQL_WARNING_THRESHOLD``
174185

175186
Default: ``500``

docs/tips.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ by disabling some configuration options that are enabled by default:
9494

9595
- ``ENABLE_STACKTRACES`` for the SQL and cache panels,
9696
- ``SHOW_TEMPLATE_CONTEXT`` for the template panel.
97+
98+
Also, check ``SKIP_TEMPLATE_PREFIXES`` when you're using template-based
99+
form widgets.

0 commit comments

Comments
 (0)