WTForms getting the errors
问题 Currently in WTForms to access errors you have to loop through field errors like so: for error in form.username.errors: print error Since I'm building a rest application which uses no form views, I'm forced to check through all form fields in order to find where the error lies. Is there a way I could do something like: for fieldName, errorMessage in form.errors: ...do something 回答1: The actual form object has an errors attribute that contains the field names and their errors in a dictionary.