mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #34388 -- Allowed using choice enumeration types directly on model and form fields.
This commit is contained in:
committed by
Mariusz Felisiak
parent
051d5944f8
commit
a2eaea8f22
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user