summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorJulian Wachholz <julian@wachholz.ch>2014-02-09 16:44:31 +0000
committerTim Graham <timograham@gmail.com>2014-02-10 07:28:39 -0500
commit9a4ee8ddb858ae07ff42be0261c867aa3d2eb53c (patch)
tree2d875068e16701a8be91f00e11578f781977c62b /docs/ref
parentb102c27ff4d21ea6262e600227530f75337a5df2 (diff)
Fixed #21994 -- Added form_dict argument to calls of WizardView.done()
Added an additional keyword argument ``form_dict`` to calls of WizardView.done() implementations which allows easier access to validated forms by their step name.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/formtools/form-wizard.txt21
1 files changed, 18 insertions, 3 deletions
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index 6a1e328ba8..5fc2a57294 100644
--- a/docs/ref/contrib/formtools/form-wizard.txt
+++ b/docs/ref/contrib/formtools/form-wizard.txt
@@ -114,11 +114,11 @@ anywhere in your codebase, but convention is to put it in :file:`views.py`.
The only requirement on this subclass is that it implement a
:meth:`~WizardView.done()` method.
-.. method:: WizardView.done(form_list)
+.. method:: WizardView.done(form_list, form_dict, **kwargs)
This method specifies what should happen when the data for *every* form is
- submitted and validated. This method is passed a list of validated
- :class:`~django.forms.Form` instances.
+ submitted and validated. This method is passed a list and dictionary of
+ validated :class:`~django.forms.Form` instances.
In this simplistic example, rather than performing any database operation,
the method simply renders a template of the validated data::
@@ -144,6 +144,21 @@ The only requirement on this subclass is that it implement a
do_something_with_the_form_data(form_list)
return HttpResponseRedirect('/page-to-redirect-to-when-done/')
+ In addition to ``form_list``, the :meth:`~WizardView.done` method
+ is passed a ``form_dict``, which allows you to access the wizard's
+ forms based on their step names. This is especially useful when using
+ :class:`NamedUrlWizardView`, for example::
+
+ def done(self, form_list, form_dict, **kwargs):
+ user = form_dict['user'].save()
+ credit_card = form_dict['credit_card'].save()
+ # ...
+
+ .. versionchanged:: 1.7
+
+ Previously, the ``form_dict`` argument wasn't passed to the
+ ``done`` method.
+
See the section :ref:`Advanced WizardView methods <wizardview-advanced-methods>`
below to learn about more :class:`WizardView` hooks.