Skip to content

Commit

Permalink
Improved documentation for form_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemParadox committed Jun 7, 2012
1 parent 22a6d87 commit 2157dc4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/topics/form-handling-class-based-views.txt
Expand Up @@ -39,6 +39,8 @@ The view can be constructed using a FormView::
success_url = '/thanks/'

def form_valid(self, form):
# This method is called when valid form data has been POSTed.
# It should return an HttpResponse.
form.send_email()
return super(ContactView, self).form_valid(form)

Expand All @@ -58,6 +60,11 @@ they can work out which model class to use:
* If ``get_object`` returns an object, the class of that object will be used
* If a ``queryset`` is given, the model for that queryset will be used

Model views provide a ``form_valid`` implementation that saves the model
automatically.
You can override/extend this method if you have any special requirements
(see below for examples).

You don't even need to provide a success_url for ``CreateView`` or
``UpdateView`` - they will use ``model.get_absolute_url()`` if available.

Expand Down

0 comments on commit 2157dc4

Please sign in to comment.