summaryrefslogtreecommitdiff
path: root/tests/model_forms/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/model_forms/tests.py')
-rw-r--r--tests/model_forms/tests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 2f96fcec30..e18b19dcac 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1499,6 +1499,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.']
+ )
+
class ModelMultipleChoiceFieldTests(TestCase):
def setUp(self):