summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/db/models/enums.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/models/enums.py b/django/db/models/enums.py
index bbe362a6ab..ae20ef6d93 100644
--- a/django/db/models/enums.py
+++ b/django/db/models/enums.py
@@ -60,7 +60,13 @@ class ChoicesMeta(enum.EnumMeta):
class Choices(enum.Enum, metaclass=ChoicesMeta):
"""Class for creating enumerated choices."""
- pass
+
+ def __str__(self):
+ """
+ Use value when cast to str, so that Choices set as model instance
+ attributes are rendered as expected in templates and similar contexts.
+ """
+ return str(self.value)
class IntegerChoices(int, Choices):