From c5ebfda00226e3695cadbc13ea9ce4c5951d3ed0 Mon Sep 17 00:00:00 2001 From: Alex Hill Date: Wed, 3 Aug 2016 11:12:06 +0800 Subject: Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect. --- tests/model_forms/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/model_forms') diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 3d65c104ff..8c706f1a56 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -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): -- cgit v1.3