diff options
| author | T. Franzel <tfranzel@users.noreply.github.com> | 2023-03-11 00:34:13 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-03-21 19:44:41 +0100 |
| commit | a2eaea8f22305b57dff3ab13add2e2887287bb6f (patch) | |
| tree | a2f1acee503899e52a583572a46aeee0d1a5432c /django/forms | |
| parent | 051d5944f86400b9b3476db60bc73de7e9964810 (diff) | |
Fixed #34388 -- Allowed using choice enumeration types directly on model and form fields.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/fields.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 46de2f53a0..003fb5ca6b 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -16,6 +16,7 @@ from urllib.parse import urlsplit, urlunsplit from django.core import validators from django.core.exceptions import ValidationError +from django.db.models.enums import ChoicesMeta from django.forms.boundfield import BoundField from django.forms.utils import from_current_timezone, to_current_timezone from django.forms.widgets import ( @@ -857,6 +858,8 @@ class ChoiceField(Field): def __init__(self, *, choices=(), **kwargs): super().__init__(**kwargs) + if isinstance(choices, ChoicesMeta): + choices = choices.choices self.choices = choices def __deepcopy__(self, memo): |
