1
我已经看过这里的问题,它们都没有帮助我的事业。基本上我正在调用getAllOpenChoices
来尝试并返回单选按钮的值,所以当选择一个时,它会保存。“ValueError:需要超过0个值才能解包”
forms.py
def getAllOpenChoices():
listOpenChoice = [('All', 'All'), ('No One', 'No One'), ('Test','Test')]
all_choices = Requisition.objects.distinct()
for choices in all_choices:
temp = (Requisition.objects.filter(open_to=choices))
listOpenChoice.append(temp)
return tuple(listOpenChoice)
,我得到这个错误是:
ValueError: need more than 0 values to unpack
getAllOpenChoices
是被称为:
self.fields['open_to'] = forms.ChoiceField(choices = getAllOpenChoices, widget = forms.RadioSelect())
完美!谢谢! –