mirror of https://github.com/django/django.git
[3.1.x] Removed forms-MAX_NUM_FORMS POST data in docs
The field is ignored server-side and only exists as a client-side
convenience. Removing it slightly simplifies the documentation and
avoids some distractions.
Added note:: for MIN_NUM_FORMS/MAX_NUM_FORMS in
Understanding the management form section.
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Backport of d3b3eb860d
from master
This commit is contained in:
parent
db1d1883e0
commit
e5273bc92b
|
@ -139,7 +139,6 @@ all forms in the formset::
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '1',
|
||||
... 'form-INITIAL_FORMS': '0',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... }
|
||||
>>> formset = ArticleFormSet(data)
|
||||
>>> formset.is_valid()
|
||||
|
@ -152,7 +151,6 @@ provide an invalid article::
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '2',
|
||||
... 'form-INITIAL_FORMS': '0',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': 'Test',
|
||||
... 'form-0-pub_date': '1904-06-16',
|
||||
... 'form-1-title': 'Test',
|
||||
|
@ -192,7 +190,6 @@ sent without any data)::
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '1',
|
||||
... 'form-INITIAL_FORMS': '0',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': '',
|
||||
... 'form-0-pub_date': '',
|
||||
... }
|
||||
|
@ -206,11 +203,10 @@ Understanding the ``ManagementForm``
|
|||
------------------------------------
|
||||
|
||||
You may have noticed the additional data (``form-TOTAL_FORMS``,
|
||||
``form-INITIAL_FORMS`` and ``form-MAX_NUM_FORMS``) that was required
|
||||
in the formset's data above. This data is required for the
|
||||
``ManagementForm``. This form is used by the formset to manage the
|
||||
collection of forms contained in the formset. If you don't provide
|
||||
this management data, an exception will be raised::
|
||||
``form-INITIAL_FORMS``) that was required in the formset's data above. This
|
||||
data is required for the ``ManagementForm``. This form is used by the formset
|
||||
to manage the collection of forms contained in the formset. If you don't
|
||||
provide this management data, the formset will be invalid::
|
||||
|
||||
>>> data = {
|
||||
... 'form-0-title': 'Test',
|
||||
|
@ -234,6 +230,15 @@ itself. When rendering a formset in a template, you can include all
|
|||
the management data by rendering ``{{ my_formset.management_form }}``
|
||||
(substituting the name of your formset as appropriate).
|
||||
|
||||
.. note::
|
||||
|
||||
As well as the ``form-TOTAL_FORMS`` and ``form-INITIAL_FORMS`` fields shown
|
||||
in the examples here, the management form also includes
|
||||
``form-MIN_NUM_FORMS`` and ``form-MAX_NUM_FORMS`` fields. They are output
|
||||
with the rest of the management form, but only for the convenience of
|
||||
client-side code. These fields are not required and so are not shown in
|
||||
the example ``POST`` data.
|
||||
|
||||
``total_form_count`` and ``initial_form_count``
|
||||
-----------------------------------------------
|
||||
|
||||
|
@ -285,7 +290,6 @@ is where you define your own validation that works at the formset level::
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '2',
|
||||
... 'form-INITIAL_FORMS': '0',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': 'Test',
|
||||
... 'form-0-pub_date': '1904-06-16',
|
||||
... 'form-1-title': 'Test',
|
||||
|
@ -326,8 +330,6 @@ deletion, is less than or equal to ``max_num``.
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '2',
|
||||
... 'form-INITIAL_FORMS': '0',
|
||||
... 'form-MIN_NUM_FORMS': '',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': 'Test',
|
||||
... 'form-0-pub_date': '1904-06-16',
|
||||
... 'form-1-title': 'Test 2',
|
||||
|
@ -368,8 +370,6 @@ deletion, is greater than or equal to ``min_num``.
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '2',
|
||||
... 'form-INITIAL_FORMS': '0',
|
||||
... 'form-MIN_NUM_FORMS': '',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': 'Test',
|
||||
... 'form-0-pub_date': '1904-06-16',
|
||||
... 'form-1-title': 'Test 2',
|
||||
|
@ -431,7 +431,6 @@ happen when the user changes these values::
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '3',
|
||||
... 'form-INITIAL_FORMS': '2',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': 'Article #1',
|
||||
... 'form-0-pub_date': '2008-05-10',
|
||||
... 'form-0-ORDER': '2',
|
||||
|
@ -533,7 +532,6 @@ delete fields you can access them with ``deleted_forms``::
|
|||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '3',
|
||||
... 'form-INITIAL_FORMS': '2',
|
||||
... 'form-MAX_NUM_FORMS': '',
|
||||
... 'form-0-title': 'Article #1',
|
||||
... 'form-0-pub_date': '2008-05-10',
|
||||
... 'form-0-DELETE': 'on',
|
||||
|
|
Loading…
Reference in New Issue