diff options
| author | Tim Graham <timograham@gmail.com> | 2017-03-15 12:54:26 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-03-15 12:55:05 -0400 |
| commit | a95616944b9cb58c2547d1f08590b3ad3a142fe2 (patch) | |
| tree | 73ca97aa982dff781d864cca558e095635e9c109 /tests/model_forms | |
| parent | 3c1ed1d336c847ed35934b3169632455505f4acb (diff) | |
[1.11.x] Refs #27563 -- Fixed ModelChoiceField.__deepcopy__() so forms don't share a queryset cache.
Thanks Luke Benstead for the report Simon Charettes for the fix.
Backport of 44f9241c48e28823b140bc4ec7515f5a88b88c32 from master
Diffstat (limited to 'tests/model_forms')
| -rw-r--r-- | tests/model_forms/tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 8b293a02ad..49ed9f03dd 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1637,6 +1637,15 @@ class ModelChoiceFieldTests(TestCase): self.assertIsNot(field1, ModelChoiceForm.base_fields['category']) self.assertIs(field1.widget.choices.field, field1) + def test_modelchoicefield_result_cache_not_shared(self): + class ModelChoiceForm(forms.Form): + category = forms.ModelChoiceField(Category.objects.all()) + + form1 = ModelChoiceForm() + self.assertCountEqual(form1.fields['category'].queryset, [self.c1, self.c2, self.c3]) + form2 = ModelChoiceForm() + self.assertIsNone(form2.fields['category'].queryset._result_cache) + def test_modelchoicefield_22745(self): """ #22745 -- Make sure that ModelChoiceField with RadioSelect widget |
