`form.validate_on_submit()` 和 `form.validate()` 之间的区别
Difference between `form.validate_on_submit()` and `form.validate()`
form.validate_on_submit()
和form.validate()
有什么区别?
在Flask WTF docs, the author uses form.validate_on_submit()
. The code works. When I substitute form.validate_on_submit()
with form.validate()
, I see no difference in behavior. I couldn't find form.validate_on_submit()
in the source, but I managed to find form.validate()
code。
validate_on_submit()
是 is_submitted() and validate()
.
的快捷方式
来自 source code,第 89 行,is_submitted()
returns 如果提交的表单是一个活动请求并且方法是 POST、PUT、PATCH 或删除。
一般来说,当路由可以同时接受 GET 和 POST 方法并且您只想对 POST 请求进行验证时使用它。
form.validate_on_submit()
和form.validate()
有什么区别?
在Flask WTF docs, the author uses form.validate_on_submit()
. The code works. When I substitute form.validate_on_submit()
with form.validate()
, I see no difference in behavior. I couldn't find form.validate_on_submit()
in the source, but I managed to find form.validate()
code。
validate_on_submit()
是 is_submitted() and validate()
.
来自 source code,第 89 行,is_submitted()
returns 如果提交的表单是一个活动请求并且方法是 POST、PUT、PATCH 或删除。
一般来说,当路由可以同时接受 GET 和 POST 方法并且您只想对 POST 请求进行验证时使用它。