mirror of
https://github.com/django/django.git
synced 2025-10-26 23:26:08 +00:00
[1.11.x] Fixed #28387 -- Fixed has_changed() for disabled form fields that subclass it.
Backport of 5debbdfcc8 from master
This commit is contained in:
committed by
Tim Graham
parent
fc6b90bdb7
commit
a3b5df8ed5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user