frommyapp.formsimportContactFormfromdjango.views.generic.editimportFormViewclassContactView(FormView):template_name='contact.html'form_class=ContactFormsuccess_url='/thanks/'defform_valid(self,form):# This method is called when valid form data has been POSTed.# It should return an HttpResponse.form.send_email()returnsuper(ContactView,self).form_valid(form)

The CreateView page displayed to a GET request uses a
template_name_suffix of '_form'. For
example, changing this attribute to '_create_form' for a view
creating objects for the example Author model would cause the
default template_name to be 'myapp/author_create_form.html'.

A view that displays a form for editing an existing object, redisplaying
the form with validation errors (if there are any) and saving changes to
the object. This uses a form automatically generated from the object’s
model class (unless a form class is manually specified).

The UpdateView page displayed to a GET request uses a
template_name_suffix of '_form'. For
example, changing this attribute to '_update_form' for a view
updating objects for the example Author model would cause the
default template_name to be 'myapp/author_update_form.html'.

A view that displays a confirmation page and deletes an existing object.
The given object will only be deleted if the request method is POST. If
this view is fetched via GET, it will display a confirmation page that
should contain a form that POSTs to the same URL.

The DeleteView page displayed to a GET request uses a
template_name_suffix of '_confirm_delete'. For
example, changing this attribute to '_check_delete' for a view
deleting objects for the example Author model would cause the
default template_name to be 'myapp/author_check_delete.html'.

This document is for Django's development version, which can be significantly different from previous releases. For older releases, use the version selector floating in the bottom right corner of this page.