错误int() argument must be a string or a number, not 'BoundField'
我的表单是多个选择框
SKILLS = ((1, 'Fly'),(2,'Run'))
class Form(forms.Form):
ability = forms.MultipleChoiceField(widget= forms.CheckboxSelectMultiple(), \
choices = SKILLS, required=False)
现在在我看来我正试图访问每个选定的数据来执行查询
if "ability" in request.POST.keys():
for ability in ability:
x = ability
sk = Skills.objects.get(id = x)
我该如何解决这个问题?
答案 0 :(得分:1)
这就是你所做的:
if "ability" in request.POST.keys():
for ability in ability:
x = ability.value()
sk = Skills.objects.get(id = x)
应该可以正常工作