Opened 4 weeks ago
Closed 4 weeks ago
#36658 closed New feature (wontfix)
Invalid numeric literal in an {% if %} tag is treated as a variable
| Reported by: | Lily | Owned by: | |
|---|---|---|---|
| Component: | Template system | Version: | 5.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I would expect the following template to raise a TemplateSyntaxError during parsing:
{% if 1.1.1 %}foo{% endif %}
Instead, the 1.1.1 is treated as a variable name, so this will render an empty string (or "foo" if the context looks like {"1": {"1": {"1": "bar"}}} or similar).
Change History (2)
comment:1 by , 4 weeks ago
| Has patch: | set |
|---|
comment:2 by , 4 weeks ago
| Easy pickings: | unset |
|---|---|
| Resolution: | → wontfix |
| Status: | new → closed |
| Type: | Bug → New feature |
Hello Lily, thank you for your ticket. Please note that this is well documented, well tested behavior. Any change in this area should be widely discussed and agreed with the Django community, with a clear deprecation plan. The current semantic has been in place for ages and it's more than likely that many projects out there rely on this behavior.
Since this can't be treated as a bug nor as a cleanup, this qualifies as a New Feature, so this idea should first be proposed and discussed with the community. To do that, please raise this on the new feature tracker.
I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.
PR: https://github.com/django/django/pull/19944