Opened 3 weeks ago

Closed 3 weeks ago

#36955 closed New feature (needsnewfeatureprocess)

Add strict template variable support with global and per-variable configuration

Reported by: Kiran Owned by:
Component: Template system Version: 6.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This proposal introduces optional strict handling for template variables.

Currently, Django silently renders missing variables as empty strings.
This feature would allow enabling a strict mode where undefined variables
raise an exception instead.

The proposal includes:

  • A global strict template variable setting.
  • Optional per-variable override behavior.
  • Backward compatibility by keeping strict mode disabled by default.

Feedback is welcome before proceeding further.

Change History (3)

comment:1 by Howard Qiu, 3 weeks ago

comment:2 by Howard Qiu, 3 weeks ago

Has patch: set
Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

This feature seems to be good, since it's hard to find the incorrect variable name if there aren't any exceptions.
Is it needed to add a screenshot when the context variable name is invalid to reproduce the issue?

comment:3 by Jacob Walls, 3 weeks ago

Needs documentation: unset
Needs tests: unset
Resolution: needsnewfeatureprocess
Status: newclosed

This is being discussed at the new-features repo

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