WTForms getting the errors

前端 未结 4 1382
一个人的身影
一个人的身影 2020-12-09 03:34

Currently in WTForms to access errors you have to loop through field errors like so:

for error in form.username.errors:
        print error

4条回答
  •  春和景丽
    2020-12-09 04:13

    For anyone looking to do this in Flask templates:

    {% for field in form.errors %}
    {% for error in form.errors[field] %}
        
    Error! {{error}}
    {% endfor %} {% endfor %}

提交回复
热议问题