0Pricing
Django Academy · Lesson

is_valid and cleaned_data

Validate input and read clean values.

Bind Data First

To validate, create a bound form by passing the submitted data into it. Only bound forms can be validated.

form = ContactForm(request.POST)

Call is_valid()

is_valid() runs every field validation and returns True only if all of them pass. It triggers the whole cleaning process.

if form.is_valid():
    handle(form)

All lessons in this course

  1. Defining a forms.Form
  2. is_valid and cleaned_data
  3. Rendering Forms in Templates
  4. CSRF Protection and the POST Flow
← Back to Django Academy