7

Advanced Form Validation and Model Forms

Continuing your journey with the form_project application you started in the previous chapter, you’ll begin this chapter by adding a new form to your app with custom multi-field validation and form cleaning. You’ll learn how to set the initial values on your form and customize the widgets (the HTML input elements that are being generated). Then, you’ll be introduced to the ModelForm class, which allows a form to be automatically created from a model. You’ll use it in a view to automatically save the new or changed Model instance.

In this chapter, we will take our knowledge of Django form validation further by introducing concepts that form the fundamentals of most production websites.

For instance, ...

Get Web Development with Django - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.