1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31154 -- Added support for using enumeration types in templates.

Enumeration helpers are callables, so the template system tried to call
them with no arguments.

Thanks Rupert Baker for helping discover this.
This commit is contained in:
Adam Johnson
2020-01-09 15:41:54 +00:00
committed by Mariusz Felisiak
parent 4c1b401e82
commit 5166097d7c
3 changed files with 10 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ class ChoicesMeta(enum.EnumMeta):
# that is passed in as "self" as the value to use when looking up the
# label in the choices.
cls.label = property(lambda self: cls._value2label_map_.get(self.value))
cls.do_not_call_in_templates = True
return enum.unique(cls)
def __contains__(cls, member):