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 , 3 weeks ago
comment:2 by , 3 weeks ago
| Has patch: | set |
|---|---|
| Needs documentation: | set |
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
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 , 3 weeks ago
| Needs documentation: | unset |
|---|---|
| Needs tests: | unset |
| Resolution: | → needsnewfeatureprocess |
| Status: | new → closed |
This is being discussed at the new-features repo
Here is the pull request: https://github.com/django/django/pull/20772