mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #28387 -- Fixed has_changed() for disabled form fields that subclass it.
This commit is contained in:
parent
2e9ada1551
commit
5debbdfcc8
8 changed files with 40 additions and 0 deletions
|
@ -1702,6 +1702,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)
|
||||
|
@ -1727,6 +1731,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue