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
- Defining a forms.Form
- is_valid and cleaned_data
- Rendering Forms in Templates
- CSRF Protection and the POST Flow