diff options
| author | Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com> | 2017-07-13 20:25:32 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-14 13:27:30 -0400 |
| commit | a3b5df8ed503ea559d2ffaca7ec0c735d98f1a38 (patch) | |
| tree | 3430d666d9322066f49390ce2a54501d485ef39c /tests/model_forms | |
| parent | fc6b90bdb7a9531e988245942f79518308616b7b (diff) | |
[1.11.x] Fixed #28387 -- Fixed has_changed() for disabled form fields that subclass it.
Backport of 5debbdfcc84266703191e084914998e38f5f52eb from master
Diffstat (limited to 'tests/model_forms')
| -rw-r--r-- | tests/model_forms/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index f33278f88a..f3317f59de 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1708,6 +1708,10 @@ class ModelChoiceFieldTests(TestCase): ['Select a valid choice. That choice is not one of the available choices.'] ) + def test_disabled_modelchoicefield_has_changed(self): + field = forms.ModelChoiceField(Author.objects.all(), disabled=True) + self.assertIs(field.has_changed('x', 'y'), False) + def test_disabled_multiplemodelchoicefield(self): class ArticleForm(forms.ModelForm): categories = forms.ModelMultipleChoiceField(Category.objects.all(), required=False) @@ -1733,6 +1737,10 @@ class ModelChoiceFieldTests(TestCase): self.assertEqual(form.errors, {}) self.assertEqual([x.pk for x in form.cleaned_data['categories']], [category1.pk]) + def test_disabled_modelmultiplechoicefield_has_changed(self): + field = forms.ModelMultipleChoiceField(Author.objects.all(), disabled=True) + self.assertIs(field.has_changed('x', 'y'), False) + def test_modelchoicefield_iterator(self): """ Iterator defaults to ModelChoiceIterator and can be overridden with |
