nim4n
nim4n

Reputation: 1829

ModelMultipleChoiceField dosen't work correctly in django form

I need a combobox in my template. so I use ModelMultipleChoiceField when I try to submit my form It said this field is empty and you must choose ! myform:

class SearchForm(forms.Form):
     type_pm = forms.ModelMultipleChoiceField(queryset=IvrModel.objects.all(), widget=forms.Select())

my template:

{% for field in form %}

     {{ field.label_tag }}
     {{ field }}
{% endfor %}

how do I fix It?

Upvotes: 0

Views: 247

Answers (1)

mariodev
mariodev

Reputation: 15559

Remove widget=forms.Select(). ModelMultipleChoiceField expects list of values, not a single value.

Upvotes: 1

Related Questions