O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required