Required boolean field?

前端 未结 2 1544
爱一瞬间的悲伤
爱一瞬间的悲伤 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:04

    Leave it as required=False and write a custom clean_is_operable method that checks that you've got what you want, else throws a ValidationError or the like

提交回复
热议问题