Fixed #16126 -- Added documentation about DELETE and ORDER fields in formsets. Many thanks to Aleksandra Sendecka.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16430 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-06-17 15:39:28 +00:00
parent 98a69a2c0a
commit 2a122be0fc
2 changed files with 31 additions and 0 deletions

View File

@ -424,6 +424,33 @@ with the management form:
The above ends up calling the ``as_table`` method on the formset class.
.. _manually-rendered-can-delete-and-can-order:
Manually rendered ``can_delete`` and ``can_order``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you manually render fields in the template, you can render
``can_delete`` parameter with ``{{ form.DELETE }}``:
.. code-block:: html+django
<form method="post" action="">
{{ formset.management_form }}
{% for form in formset %}
{{ form.id }}
<ul>
<li>{{ form.title }}</li>
{% if formset.can_delete %}
<li>{{ form.DELETE }}</li>
{% enif %}
</ul>
{% endfor %}
</form>
Similarly, if the formset has the ability to order (``can_order=True``), it is possible to render it
with ``{{ form.ORDER }}``.
Using more than one formset in a view
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -831,6 +831,10 @@ a particular author, you could do this::
``inlineformset_factory`` uses ``modelformset_factory`` and marks
``can_delete=True``.
.. seealso::
:ref:`Manually rendered can_delete and can_order <manually-rendered-can-delete-and-can-order>`.
More than one foreign key to the same model
-------------------------------------------