1
0
mirror of https://github.com/django/django.git synced 2025-06-07 04:29:12 +00:00

[5.1.x] Fixed #35843 -- Clarified formset docs about reordering forms.

Backport of 299b072498b23d1d7fe9f1545f7b27b73ca8e22b from main.
This commit is contained in:
Clifford Gama 2024-11-13 20:14:16 +02:00 committed by Natalia
parent d71c588d83
commit 4c5455d25c

View File

@ -48,13 +48,10 @@ following example will create a formset class to display two blank forms:
>>> ArticleFormSet = formset_factory(ArticleForm, extra=2) >>> ArticleFormSet = formset_factory(ArticleForm, extra=2)
Iterating over a formset will render the forms in the order they were Formsets can be iterated and indexed, accessing forms in the order they were
created. You can change this order by providing an alternate implementation for created. You can reorder the forms by overriding the default
the ``__iter__()`` method. :py:meth:`iteration <object.__iter__>` and
:py:meth:`indexing <object.__getitem__>` behavior if needed.
Formsets can also be indexed into, which returns the corresponding form. If you
override ``__iter__``, you will need to also override ``__getitem__`` to have
matching behavior.
.. _formsets-initial-data: .. _formsets-initial-data: