1
0
mirror of https://github.com/django/django.git synced 2025-10-26 23:26:08 +00:00

[1.10.x] Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect.

Backport of c5ebfda002 from master
This commit is contained in:
Alex Hill
2016-08-03 11:12:06 +08:00
committed by Tim Graham
parent a8b8ef114d
commit 86ae2b22ae
3 changed files with 16 additions and 2 deletions

View File

@@ -1539,6 +1539,14 @@ class ModelChoiceFieldTests(TestCase):
self.assertEqual(form.errors, {})
self.assertEqual([x.pk for x in form.cleaned_data['categories']], [category1.pk])
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):