python表单验证wtf_flaskwtf validate_on_submit()将始终返回tru

我对烧瓶不熟悉。我根据文档进行了验证,但是validate_on_submit()返回的结果始终为true,而没有按照规则进行验证。我是遗漏了什么还是做错了什么?在

形式:from flask_wtf import FlaskForm

from wtforms import StringField, TextAreaField, BooleanField

from wtforms.validators import DataRequired, Length, Optional

class TemplateCreateForm(FlaskForm):

title = StringField([Length(min=4, max=45), DataRequired()])

view_path = StringField([Length(min=1, max=45), DataRequired()])

caption = TextAreaField([Length(min=5, max=250), Optional()])

is_active = BooleanField([DataRequired()])

在控制器.py在

^{pr2}$

在视图.html在

Template creation
{{ form.hidden_tag() }} {{ form.csrf_token }}

Title * {{ form.title(class_='form-control') }}

Caption {{ form.caption(class_='form-control') }}

View * {{ form.view_path(class_='form-control') }}

{{ form.is_active(class_='form-check-input') }} Active

{% for message in form.errors %} {{ message }} {% endfor %}

Submit

你可能感兴趣的:(python表单验证wtf)