Wednesday, 21 August 2013

how to pull array of results from http Post result of ModelMultipleChoiceField in django view

how to pull array of results from http Post result of
ModelMultipleChoiceField in django view

I print the request POST after submitting a form with a
ModelMultipleChoiceField
if request.method == 'POST':
print 'form ' + str(request.POST)
for i in request.POST['groups_field']:
print i
This first print prints this:
form
The second print prints this:
4
Why does this only pull the last selected value?
The form field looks like this:
groups_field = forms.ModelMultipleChoiceField(queryset=Group.objects.none(),
widget=forms.CheckboxSelectMultiple)
How can I pull out the list of group fields selected?

No comments:

Post a Comment