mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect.
This commit is contained in:
@@ -1576,6 +1576,14 @@ class ModelChoiceFieldTests(TestCase):
|
||||
field = CustomModelChoiceField(Category.objects.all())
|
||||
self.assertIsInstance(field.choices, CustomModelChoiceIterator)
|
||||
|
||||
def test_radioselect_num_queries(self):
|
||||
class CategoriesForm(forms.Form):
|
||||
categories = forms.ModelChoiceField(Category.objects.all(), widget=forms.RadioSelect)
|
||||
|
||||
template = Template('{% for widget in form.categories %}{{ widget }}{% endfor %}')
|
||||
with self.assertNumQueries(2):
|
||||
template.render(Context({'form': CategoriesForm()}))
|
||||
|
||||
|
||||
class ModelMultipleChoiceFieldTests(TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user