如何修复“M”值必须为 True 或 False

问题描述

This is my model.py where my gender is a booleanfield

This is my forms.py where i put my gender as a choicefield and the widget is radioselect

Maybe my wrong is in the views.py but i don't know how to fix

This is the error that i need to fix Please help me

解决方法

data = {'first_name': form.cleaned_data.get('first_name'),....}
data['gender'] = True if form.cleaned_data.get('gender') == 'M' else False
mo = Monitor.objects.create(**data)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...