Skip to content

Commit

Permalink
panels(templates): avoid evaluating LazyObject
Browse files Browse the repository at this point in the history
LazyObject is typically used for something expensive to evaluate, so avoid evaluating it just for showing it in the debug toolbar.
  • Loading branch information
nijel committed Sep 19, 2023
1 parent 199c2b3 commit 17dbfae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion debug_toolbar/panels/templates/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ def _store_template_info(self, sender, **kwargs):
if pformatted is None:
temp_layer = {}
for key, value in context_layer.items():
# Do not force evaluating LazyObject
if hasattr(value, "_wrapped"):
temp_layer[key] = repr(value)
# Replace any request elements - they have a large
# Unicode representation and the request data is
# already made available from the Request panel.
if isinstance(value, http.HttpRequest):
elif isinstance(value, http.HttpRequest):
temp_layer[key] = "<<request>>"
# Replace the debugging sql_queries element. The SQL
# data is already made available from the SQL panel.
Expand Down

0 comments on commit 17dbfae

Please sign in to comment.