1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect.

This commit is contained in:
Alex Hill
2016-08-03 11:12:06 +08:00
committed by Tim Graham
parent 4e64e3bb6e
commit c5ebfda002
3 changed files with 16 additions and 2 deletions

View File

@@ -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):