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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user