Not able to pass logical answer received from Form to NullBoolean model

ساخت وبلاگ

Vote count: 0

My model is like

 class mymodel(models.Model): param1=models.NullBooleanField(blank=False)

My form is

class MyForm01(forms.Form): LCHOICES=[(True, 'Yes'),(False,'No')] answer=forms.ChoiceField( label='Question', choices=LCHOICES, widget=forms.RadioSelect(), help_text='Help text')

I am trying to pass the user choice to a model for saving as below, where id_number is a new number for new object creation.

 myobj=mymodel.objects.create( id=mymodel.objects.get(id=id_number), param1=form.cleaned_data.['answer'] )

Everything happens, including new object creation but the data passed is always True even when the original answer is negative. If I take a print of answer its coming as False. Also if I change form.cleaned_data.['answer'] to False, it is well accepted.

Where am I making a mistake?

asked 44 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : not able to sleep,not able to,not able to read,not able to hear,not able to connect to internet,not able to breathe,not able to swallow,not able to download apps,not able to pee, نویسنده : استخدام کار backsoft بازدید : 355 تاريخ : يکشنبه 31 مرداد 1395 ساعت: 13:35