0PricingLogin
Flask Academy · Lesson

validate_on_submit and CSRF Tokens

Process valid posts and block forgeries.

The Golden Method

Flask-WTF gives you one method that checks everything at once. validate_on_submit is the heart of safely processing any form. 🔑

What It Actually Checks

validate_on_submit returns True only when the request is a POST and every validator passes. One call covers both conditions.

if form.validate_on_submit():
    pass  # safe to use the data

All lessons in this course

  1. Define a FlaskForm Class
  2. Render and Submit a Form
  3. validate_on_submit and CSRF Tokens
  4. Custom Validators and Field Errors
← Back to Flask Academy