#31154 closed Bug (fixed)
Enumeration Types are not usable in templates.
Reported by: | Adam Johnson | Owned by: | Adam Johnson |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.0 |
Severity: | Release blocker | 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 (last modified by )
The new enumeration types are great but can't be used in Django templates due to their being callable. For example this doesn't work:
{% if student.year_in_school == YearInSchool.FRESHMAN %}
This is because YearInSchool, being a class, is callable, and Django Templates always call callables with no arguments. The call fails because the required value
argument is missing.
The easy solution would be to declare do_not_call_in_templates = True
on the various Choices classes.
Change History (4)
comment:1 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
Component: | Template system → Database layer (models, ORM) |
---|---|
Description: | modified (diff) |
Has patch: | set |
Severity: | Normal → Release blocker |
Summary: | Enumeration Types not usable in templates → Enumeration Types are not usable in templates. |
Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
PR