Required boolean field?

前端 未结 2 1540
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 18:23

I\'ve got a boolean field,

is_operable = BooleanField(widget=RadioSelect(choices=YES_OR_NO, renderer=InlineRadioFieldRenderer), required=False, initial=True)         


        
2条回答
  •  时光说笑
    2021-01-19 19:15

    I would recommend using a TypedChoiceField which coerces the choices YES_OR_NO into a boolean. See the docs: http://docs.djangoproject.com/en/1.2/ref/forms/fields/#django.forms.TypedChoiceField

提交回复
热议问题