Determine why WTForms form didn't validate

陌路散爱 提交于 2020-03-10 05:00:08

问题


I called form.validate_on_submit(), but it returned False. How can I find out why the form didn't validate?


回答1:


For the whole form, form.errors contains a map of fields to lists of errors. If it is not empty, then the form did not validate. For an individual field, field.errors contains a list of errors for that field. The list is the same as the one in form.errors.

form.validate() performs validation and populates errors. When using Flask-WTF, form.validate_on_submit() performs an additional check that request.method is a "submit" method, which mostly means it is not a GET request.



来源:https://stackoverflow.com/questions/39558984/determine-why-wtforms-form-didnt-validate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!