ModelMultipleChoiceField validation works differently depending on the widget

I have a form with ModelMultipleChoiceField

and it works like a charm. However, when I install widget=forms.RadioSelect

, the form validation always fails with an "Please enter a list of values" error message.

As I said, it works fine with the default widgets, but not with the radio selection widgets. The request POST

for validating the form is exactly the same, everything is exactly the same except for the widget, so I can't figure out what I'm doing wrong.

Why is this?

EDIT: Perhaps I should have mentioned what it works with CheckboxSelectMultiple

.

EDIT2: It doesn't even seem like I'm setting required=False

, it still tells me to "enter a list of values".

+1


a source to share


1 answer


Wow, I was squinting at the piano. Of course it ModelMultipleChoiceField

doesn't work with RadioSelect

, because the radio button list means there can only be one choice. The solution is to use ModelChoiceField

.



+2


a source







All Articles