summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
authorAlex Hill <alex@hill.net.au>2016-08-03 11:12:06 +0800
committerTim Graham <timograham@gmail.com>2016-08-03 10:53:42 -0400
commit86ae2b22ae2b0e11a4f20785afd5c475a94e59a7 (patch)
tree589e4de5dd233173ecd540c79319a7910949ce51 /tests/model_forms
parenta8b8ef114dd01d9c1e71a620b732b9aac7b7da5c (diff)
[1.10.x] Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect.
Backport of c5ebfda00226e3695cadbc13ea9ce4c5951d3ed0 from master
Diffstat (limited to 'tests/model_forms')
-rw-r--r--tests/model_forms/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 0b0390707e..f03c80fb6b 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -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):