1

我在提交带有 ModelMultipleChoiceField 的表单后打印请求 POST

if request.method == 'POST':
            print 'form ' + str(request.POST)
            for i in request.POST['groups_field']:
                print i

第一次打印打印:

形式

第二个打印打印:

4

为什么这只拉最后一个选定的值?

表单字段如下所示:

groups_field = forms.ModelMultipleChoiceField(queryset=Group.objects.none(), 
                                    widget=forms.CheckboxSelectMultiple)

如何拉出选定的组字段列表?

4

1 回答 1

2

尝试使用request.POST.getlist('groups_field')

于 2013-08-21T23:51:55.813 回答