#31154: Enumeration Types not usable in templates
-------------------------------------------------+------------------------
               Reporter:  Adam (Chainz) Johnson  |          Owner:  nobody
                   Type:  Bug                    |         Status:  new
              Component:  Template system        |        Version:  3.0
               Severity:  Normal                 |       Keywords:
           Triage Stage:  Unreviewed             |      Has patch:  0
    Needs documentation:  0                      |    Needs tests:  0
Patch needs improvement:  0                      |  Easy pickings:  0
                  UI/UX:  0                      |
-------------------------------------------------+------------------------
 The new [enumeration
 types](https://docs.djangoproject.com/en/3.0/ref/models/fields
 /#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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31154>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.1e1b8be0283e933ba74a2c414c6b3bf2%40djangoproject.com.

Reply via email to