I had a strange problem with the WTForms library. For tests, I created a form with one field:
class ArticleForm(Form): content = TextField('Content')
It gets a simple string as content, and now I use form.validate() , and it returns False for any reason.
I looked at the validate() methods of the 'Form and Field object. I found out that the field returns true if the length of the error list is zero. This is true for my test, since I am not getting any errors. In the shell, checking my field returns True as expected.
The validate() method in the Form object simply runs on the fields and calls their validate() method and returns only false if one of the fields is checked as false.
Since my field is checked without errors, I see no reason in the code why form.validate() returns False .
Any ideas?
python wtforms
Ovid
source share