diff options
| author | Tim Graham <timograham@gmail.com> | 2016-07-25 14:04:39 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-07-27 08:14:14 -0400 |
| commit | a5f85d891b51d7ceb4f9e422e3e4f5c741062288 (patch) | |
| tree | c12b7c8bb54fbb373105a0bd8e263ced612b0edf /tests/model_forms | |
| parent | 0d1218896f3dcd9a37d44c123d936e5fe8cea416 (diff) | |
Fixed #26917 -- Fixed crash in disabled ModelChoiceFields.
Partially reverted refs #25532 to fix a regression in Django 1.10.
This reintroduces a crash for disabled forms.JSONField (refs #26949),
however, that issue is also present on Django 1.9.
Thanks Ryan Schave for the test.
Diffstat (limited to 'tests/model_forms')
| -rw-r--r-- | tests/model_forms/tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 9de1a7f24b..daf36c8fc2 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -1519,6 +1519,21 @@ class ModelChoiceFieldTests(TestCase): '<label><input name="foo" type="radio" value="" /> ---------</label>' ) + def test_disabled_modelchoicefield(self): + class ModelChoiceForm(forms.ModelForm): + author = forms.ModelChoiceField(Author.objects.all(), disabled=True) + + class Meta: + model = Book + fields = ['author'] + + book = Book.objects.create(author=Writer.objects.create(name='Test writer')) + form = ModelChoiceForm({}, instance=book) + self.assertEqual( + form.errors['author'], + ['Select a valid choice. That choice is not one of the available choices.'] + ) + def test_modelchoicefield_iterator(self): """ Iterator defaults to ModelChoiceIterator and can be overridden with |
