Opened 9 years ago

Last modified 11 days ago

#28526 new Cleanup/optimization

Remedy verbose, often unhelpful undefined template variable logging

Reported by: Tim Graham Owned by:
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Adam Johnson Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As discussed on django-developers, ticket #18773 added logging of undefined template variables in Django 1.9 [dc5b01ad05e50ccde688c73c2ed3334a956076b0], however, I've seen several reports of users finding this logging more confusing than helpful. For example, admin templates log errors about missing is_popup variables which is how the template are designed (is_popup is only in the contexts of pop ups) and the TECHNICAL_404_TEMPLATE (now django/views/templates/technical_404.html) also logs errors (#26886) without any obvious solution about how to prevent that. Also #28516 shows the many warnings logged for an admin changelist page.

Change History (15)

comment:1 by Tim McCurrach, 3 years ago

Owner: changed from nobody to Tim McCurrach
Status: newassigned

comment:2 by Tim McCurrach, 3 years ago

Owner: Tim McCurrach removed
Status: assignednew

comment:3 by Adam Johnson, 19 months ago

Cc: Adam Johnson added

comment:4 by Natalia Bidart, 19 months ago

Ticket #35716 is related, possibly a duplicate.

comment:5 by Sarah Boyce, 6 months ago

Has patch: set
Owner: set to Jacob Walls
Status: newassigned

comment:6 by Sarah Boyce, 6 months ago

Patch needs improvement: set

comment:7 by Jacob Walls, 6 months ago

Patch needs improvement: unset

comment:8 by Jacob Walls, 6 months ago

Summary: Remedy verbose, often unhelpful undefined tempate variable loggingRemedy verbose, often unhelpful undefined template variable logging

comment:9 by Sarah Boyce, 6 months ago

Triage Stage: AcceptedReady for checkin

comment:10 by Sarah Boyce <42296566+sarahboyce@…>, 6 months ago

In 7894776b:

Refs #28526 -- Provided URLResolver namespace in technical 404 template.

This avoids looking up the nonexistent "name" attribute on URLResolver,
which logs verbosely.

comment:11 by Sarah Boyce, 6 months ago

Has patch: unset
Owner: Jacob Walls removed
Status: assignednew
Triage Stage: Ready for checkinAccepted

comment:12 by Mankameshwar Mishra, 12 days ago

Hi, I’d like to work on this ticket if it’s still available. Please let me know if I can take it.

comment:13 by Tim Graham, 11 days ago

What's your proposal on how to address it?

comment:14 by Mankameshwar Mishra, 11 days ago

Thanks for the question.

My understanding is that the current logging for undefined template variables can be very verbose and sometimes confusing, especially in cases where missing variables are expected (e.g., optional template context variables).

My proposal is to improve this by making the logging less noisy. For example, we could avoid logging repeated messages for the same undefined variable within a single template render, or adjust the message so it is clearer and more actionable for developers.

I will first investigate where the logging is triggered in the template engine and propose a minimal change that reduces unnecessary verbosity while keeping useful debugging information.

Please let me know if this approach sounds reasonable.

comment:15 by Tim Graham, 11 days ago

I don't care to engage with contributors using AI.

Note: See TracTickets for help on using tickets.
Back to Top