Module 07 of 12

Forms & Validation

Lessons

About This Module

Almost every real application has to accept input from users: sign-up pages, contact forms, search boxes, and content editors. Handling that input safely is harder than it looks, because you have to render fields, read the submitted data, check that it is valid, and show helpful errors. Django's forms framework does this work for you.

In this module you will learn how to define a form with the Form class, how to build one directly from a model with ModelForm, and how to render it in a template and process it in a view on POST. You will then learn how validation works: built-in field checks, custom validators, and clean() methods for rules that involve more than one field, along with how to display error messages.

Watch the lessons in order, then continue on to Authentication & Permissions. Some of these videos were recorded on older Django releases, so check the official documentation if a detail differs on your install.

Lessons

4 videos
01

How to Handle Forms in Django

Covers creating a form class with forms.Form and ModelForm, rendering forms in templates, handling POST requests, validating and cleaning data, and displaying error messages.

02

Django Forms Explained: Normal Form vs ModelForm vs HTML Manual Form

Compares a regular Django form, a ModelForm, and a manually written HTML form, so you can choose the right approach for each situation.

03

Python Django Tutorial #8: Django ModelForm, Django Model Forms

Shows how to bind a form to a model using the ModelForm class.

04

Simple Power of Django Validators // Form Validation // Model Validation

Covers form validation, model validation, and writing custom validators.