Making a contact form

Although we iterated over the book search form example several times and improved it nicely, it's still fundamentally simple: just a single field, 'q'. As forms get more complex, we have to repeat the preceding steps over and over again for each form field we use. This introduces a lot of cruft and a lot of opportunities for human error. Lucky for us, the Django developers thought of this and built into Django a higher-level library that handles form-and validation-related tasks.

Your first form class

Django comes with a form library, called django.forms, that handles many of the issues we've been exploring this chapter-from HTML form display to validation. Let's dive in and rework our contact form application using the Django ...

Get Mastering Django: Core 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.