mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +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:
committed by
Tim Graham
parent
06172d7bc2
commit
40f0aa9885
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user