Django CheckboxSelectMultiple Data in View: BoundField Type Error
The error int() argument must be a string or 开发者_如何转开发a number, not 'BoundField'
My form is a multiplechoicefield
SKILLS = ((1, 'Fly'),(2,'Run'))
class Form(forms.Form):
ability = forms.MultipleChoiceField(widget= forms.CheckboxSelectMultiple(), \
choices = SKILLS, required=False)
now in my view i am trying to access each of the selcted data to perform a query
if "ability" in request.POST.keys():
for ability in ability:
x = ability
sk = Skills.objects.get(id = x)
How can i fix this?
this is what you do:
if "ability" in request.POST.keys():
for ability in ability:
x = ability.value()
sk = Skills.objects.get(id = x)
should work fine
精彩评论