7. Advanced Form Validation and Model Forms

Overview

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

By the end of this chapter, you will know how to add extra multi-field validation to Django forms, how to customize and set form widgets for fields, how to use ModelForms to automatically create ...

Get Web Development with Django 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.