Pre-populating a BooleanField as checked (WTForms)

后端 未结 8 2738
耶瑟儿~
耶瑟儿~ 2021-02-19 04:44

For the life of me, I can\'t figure out how to pre-populate a BooleanField with WTForms. I have a field called \"active\". It defaults to being not checked, and it\'s not requ

8条回答
  •  生来不讨喜
    2021-02-19 05:21

    If you have an object you can use it to populate your form like form = QuestionForm(obj=my_obj). If you only want to set the active attribute use form = QuestionForm(active=True).

提交回复
热议问题