Refs #26813 -- Added test for ModelChoiceField.choices when using RadioSelect widget.
This commit is contained in:
parent
335c9c94ac
commit
1d5fb35e6a
|
@ -259,6 +259,20 @@ class ModelFormBaseTest(TestCase):
|
||||||
award = form.save()
|
award = form.save()
|
||||||
self.assertIsNone(award.character)
|
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):
|
def test_save_blank_false_with_required_false(self):
|
||||||
"""
|
"""
|
||||||
A ModelForm with a model with a field set to blank=False and the form
|
A ModelForm with a model with a field set to blank=False and the form
|
||||||
|
|
Loading…
Reference in New Issue