11.3.1 Contact Form

The goal of the contact page is to enable users to give us feedback on our site. To that end, we want to present users with a form that allows them to write feedback and gives us a way to contact them in the event they want us to. Without a model, we need to build the form as a Form (Example 11.5) instead of as a ModelForm as we did previously.

Example 11.5: Project Code

contact/forms.py in 3969d84738

 1   from django import forms  .       ...  6   class ContactForm(forms.Form):  .       ... 18       email = forms.EmailField( 19           initial='youremail@domain.com') 20       text = forms.CharField(widget=forms.Textarea)

By default, a forms.CharField (as opposed to models.CharField) presents ...

Get Django Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.