Chapter 5: Django Forms
In programming, a form is an object that contains input fields, drop-down boxes, radio buttons, checkboxes, and a submit button. The duty of the form is to capture information from the user; what is done after that can be anything including storing that information in a database, sending an email, or generating a reporting document using that data. In this chapter, we discuss as much as we can about how forms are used in Django. Form objects are a very complex subject to discuss; we only have enough room in this chapter to cover the essentials and some advanced topics. Some of the topics in this chapter can be combined with other topics covered later in Chapter 8, Working with the Django REST Framework, to create form objects on SPA-like pages.
In our first form, we will create a class called ContactForm
and build an email field in three different ways. Later, when we render that form in the browser, we will observe how its behavior changes using those three...