diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index 8259b3b8bd..a4e1ee1183 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -259,6 +259,20 @@ class ModelFormBaseTest(TestCase): award = form.save() self.assertIsNone(award.character) + def test_blank_foreign_key_with_radio(self): + class BookForm(forms.ModelForm): + class Meta: + model = Book + fields = ['author'] + widgets = {'author': forms.RadioSelect()} + + writer = Writer.objects.create(name='Joe Doe') + form = BookForm() + self.assertEqual(list(form.fields['author'].choices), [ + ('', '---------'), + (writer.pk, 'Joe Doe'), + ]) + def test_save_blank_false_with_required_false(self): """ A ModelForm with a model with a field set to blank=False and the form