mirror of
https://github.com/django/django.git
synced 2025-07-29 08:04:27 +00:00
Fixed #29158 -- Fixed len(choices) crash if ModelChoiceField's queryset is a manager.
Removing all() in __iter__() prevents a duplicate query when choices are cast to a list and there's a prefetch_related().
This commit is contained in:
parent
06172d7bc2
commit
40f0aa9885
3 changed files with 4 additions and 3 deletions
|
@ -249,6 +249,7 @@ class ModelChoiceFieldTests(TestCase):
|
|||
|
||||
def test_queryset_manager(self):
|
||||
f = forms.ModelChoiceField(Category.objects)
|
||||
self.assertEqual(len(f.choices), 4)
|
||||
self.assertEqual(list(f.choices), [
|
||||
('', '---------'),
|
||||
(self.c1.pk, 'Entertainment'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue