开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜