summaryrefslogtreecommitdiff
path: root/django/forms/models.py
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2023-08-31 02:57:40 +0100
committerGitHub <noreply@github.com>2023-08-30 22:57:40 -0300
commit500e01073adda32d5149624ee9a5cb7aa3d3583f (patch)
treef9416872a811aa39646deaf002414e0a7841b6d1 /django/forms/models.py
parent68a8996bdfce2d191decd7b1c1a2b9fdea8e4b2f (diff)
Fixed #31262 -- Added support for mappings on model fields and ChoiceField's choices.
Diffstat (limited to 'django/forms/models.py')
-rw-r--r--django/forms/models.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index dc30d79b5d..d353da4ddc 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -21,6 +21,7 @@ from django.forms.widgets import (
RadioSelect,
SelectMultiple,
)
+from django.utils.choices import ChoiceIterator
from django.utils.text import capfirst, get_text_list
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
@@ -1402,7 +1403,7 @@ class ModelChoiceIteratorValue:
return self.value == other
-class ModelChoiceIterator:
+class ModelChoiceIterator(ChoiceIterator):
def __init__(self, field):
self.field = field
self.queryset = field.queryset
@@ -1532,7 +1533,7 @@ class ModelChoiceField(ChoiceField):
# the queryset.
return self.iterator(self)
- choices = property(_get_choices, ChoiceField._set_choices)
+ choices = property(_get_choices, ChoiceField.choices.fset)
def prepare_value(self, value):
if hasattr(value, "_meta"):