0
我想要一個複選框的形式,其中可以檢查多個選項。爲此,我有:Django窗體:MultipleChoiceField錯誤太多的值來解壓
forms.py
class ServiceForm(forms.Form):
services = ServiceList.objects.all().values('service_name')
choice = []
for x in services:
choice.extend(x.values())
service_id = forms.MultipleChoiceField(required=True,
widget=forms.CheckboxSelectMultiple, choices=choice)
views.py
def save_data_into_temp(request):
if request.method == 'POST':
detail_form = ServiceForm(data=request.POST)
if detail_form.is_valid():
detail = detail_form.save(commit=False)
detail.save()
但是這是給我的錯誤
too many values to unpack
回溯:在line 58 錯誤
58 {{ service_form }}
哪一行會拋出錯誤? – 2015-04-03 20:35:17