Skip to content

Commit 17dbfae

Browse files
authored
panels(templates): avoid evaluating LazyObject
LazyObject is typically used for something expensive to evaluate, so avoid evaluating it just for showing it in the debug toolbar.
1 parent 199c2b3 commit 17dbfae

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

debug_toolbar/panels/templates/panel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ def _store_template_info(self, sender, **kwargs):
9696
if pformatted is None:
9797
temp_layer = {}
9898
for key, value in context_layer.items():
99+
# Do not force evaluating LazyObject
100+
if hasattr(value, "_wrapped"):
101+
temp_layer[key] = repr(value)
99102
# Replace any request elements - they have a large
100103
# Unicode representation and the request data is
101104
# already made available from the Request panel.
102-
if isinstance(value, http.HttpRequest):
105+
elif isinstance(value, http.HttpRequest):
103106
temp_layer[key] = "<<request>>"
104107
# Replace the debugging sql_queries element. The SQL
105108
# data is already made available from the SQL panel.

0 commit comments

Comments
 (0)