mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #19516 - Fixed remaining broken links.
Added -n to sphinx builds to catch issues going forward.
This commit is contained in:
@@ -25,9 +25,8 @@ application takes care of the following workflow:
|
||||
a. If it's valid, displays a preview page.
|
||||
b. If it's not valid, redisplays the form with error messages.
|
||||
3. When the "confirmation" form is submitted from the preview page, calls
|
||||
a hook that you define -- a
|
||||
:meth:`~django.contrib.formtools.preview.FormPreview.done()` method that gets
|
||||
passed the valid data.
|
||||
a hook that you define -- a ``done()`` method that gets passed the valid
|
||||
data.
|
||||
|
||||
The framework enforces the required preview by passing a shared-secret hash to
|
||||
the preview page via hidden form fields. If somebody tweaks the form parameters
|
||||
@@ -51,8 +50,7 @@ How to use ``FormPreview``
|
||||
directory to your :setting:`TEMPLATE_DIRS` setting.
|
||||
|
||||
2. Create a :class:`~django.contrib.formtools.preview.FormPreview` subclass that
|
||||
overrides the :meth:`~django.contrib.formtools.preview.FormPreview.done()`
|
||||
method::
|
||||
overrides the ``done()`` method::
|
||||
|
||||
from django.contrib.formtools.preview import FormPreview
|
||||
from myapp.models import SomeModel
|
||||
@@ -92,13 +90,15 @@ How to use ``FormPreview``
|
||||
A :class:`~django.contrib.formtools.preview.FormPreview` class is a simple Python class
|
||||
that represents the preview workflow.
|
||||
:class:`~django.contrib.formtools.preview.FormPreview` classes must subclass
|
||||
``django.contrib.formtools.preview.FormPreview`` and override the
|
||||
:meth:`~django.contrib.formtools.preview.FormPreview.done()` method. They can live
|
||||
anywhere in your codebase.
|
||||
``django.contrib.formtools.preview.FormPreview`` and override the ``done()``
|
||||
method. They can live anywhere in your codebase.
|
||||
|
||||
``FormPreview`` templates
|
||||
=========================
|
||||
|
||||
.. attribute:: FormPreview.form_template
|
||||
.. attribute:: FormPreview.preview_template
|
||||
|
||||
By default, the form is rendered via the template :file:`formtools/form.html`,
|
||||
and the preview page is rendered via the template :file:`formtools/preview.html`.
|
||||
These values can be overridden for a particular form preview by setting
|
||||
|
||||
@@ -54,7 +54,8 @@ you just have to do these things:
|
||||
4. Add ``django.contrib.formtools`` to your
|
||||
:setting:`INSTALLED_APPS` list in your settings file.
|
||||
|
||||
5. Point your URLconf at your :class:`WizardView` :meth:`~WizardView.as_view` method.
|
||||
5. Point your URLconf at your :class:`WizardView` :meth:`~WizardView.as_view`
|
||||
method.
|
||||
|
||||
Defining ``Form`` classes
|
||||
-------------------------
|
||||
@@ -89,6 +90,9 @@ the message itself. Here's what the :file:`forms.py` might look like::
|
||||
Creating a ``WizardView`` subclass
|
||||
----------------------------------
|
||||
|
||||
.. class:: SessionWizardView
|
||||
.. class:: CookieWizardView
|
||||
|
||||
The next step is to create a
|
||||
:class:`django.contrib.formtools.wizard.views.WizardView` subclass. You can
|
||||
also use the :class:`SessionWizardView` or :class:`CookieWizardView` classes
|
||||
@@ -225,9 +229,11 @@ Here's a full example template:
|
||||
Hooking the wizard into a URLconf
|
||||
---------------------------------
|
||||
|
||||
.. method:: WizardView.as_view
|
||||
|
||||
Finally, we need to specify which forms to use in the wizard, and then
|
||||
deploy the new :class:`WizardView` object at a URL in the ``urls.py``. The
|
||||
wizard's :meth:`as_view` method takes a list of your
|
||||
wizard's ``as_view()`` method takes a list of your
|
||||
:class:`~django.forms.Form` classes as an argument during instantiation::
|
||||
|
||||
from django.conf.urls import patterns
|
||||
@@ -346,9 +352,9 @@ Advanced ``WizardView`` methods
|
||||
used as the form for step ``step``.
|
||||
|
||||
Returns an :class:`~django.db.models.Model` object which will be passed as
|
||||
the :attr:`~django.forms.ModelForm.instance` argument when instantiating the
|
||||
ModelForm for step ``step``. If no instance object was provided while
|
||||
initializing the form wizard, ``None`` will be returned.
|
||||
the ``instance`` argument when instantiating the ``ModelForm`` for step
|
||||
``step``. If no instance object was provided while initializing the form
|
||||
wizard, ``None`` will be returned.
|
||||
|
||||
The default implementation::
|
||||
|
||||
@@ -514,10 +520,10 @@ Providing initial data for the forms
|
||||
.. attribute:: WizardView.initial_dict
|
||||
|
||||
Initial data for a wizard's :class:`~django.forms.Form` objects can be
|
||||
provided using the optional :attr:`~Wizard.initial_dict` keyword argument.
|
||||
This argument should be a dictionary mapping the steps to dictionaries
|
||||
containing the initial data for each step. The dictionary of initial data
|
||||
will be passed along to the constructor of the step's
|
||||
provided using the optional :attr:`~WizardView.initial_dict` keyword
|
||||
argument. This argument should be a dictionary mapping the steps to
|
||||
dictionaries containing the initial data for each step. The dictionary of
|
||||
initial data will be passed along to the constructor of the step's
|
||||
:class:`~django.forms.Form`::
|
||||
|
||||
>>> from myapp.forms import ContactForm1, ContactForm2
|
||||
@@ -542,11 +548,13 @@ Providing initial data for the forms
|
||||
Handling files
|
||||
==============
|
||||
|
||||
.. attribute:: WizardView.file_storage
|
||||
|
||||
To handle :class:`~django.forms.FileField` within any step form of the wizard,
|
||||
you have to add a :attr:`file_storage` to your :class:`WizardView` subclass.
|
||||
you have to add a ``file_storage`` to your :class:`WizardView` subclass.
|
||||
|
||||
This storage will temporarily store the uploaded files for the wizard. The
|
||||
:attr:`file_storage` attribute should be a
|
||||
``file_storage`` attribute should be a
|
||||
:class:`~django.core.files.storage.Storage` subclass.
|
||||
|
||||
Django provides a built-in storage class (see :ref:`the built-in filesystem
|
||||
@@ -646,6 +654,8 @@ Usage of ``NamedUrlWizardView``
|
||||
===============================
|
||||
|
||||
.. class:: NamedUrlWizardView
|
||||
.. class:: NamedUrlSessionWizardView
|
||||
.. class:: NamedUrlCookieWizardView
|
||||
|
||||
There is a :class:`WizardView` subclass which adds named-urls support to the
|
||||
wizard. By doing this, you can have single urls for every step. You can also
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
django.contrib.formtools
|
||||
========================
|
||||
|
||||
.. module:: django.contrib.formtools
|
||||
|
||||
A set of high-level abstractions for Django forms (:mod:`django.forms`).
|
||||
|
||||
.. toctree::
|
||||
|
||||
Reference in New Issue
Block a user