summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-10-25 12:50:02 -0700
committerCarlton Gibson <carlton.gibson@noumenal.es>2020-12-23 17:19:00 +0100
commite5273bc92b3fbba56b3f4b536c6b5fc2c34ea371 (patch)
treec0517a7dbc0d6f5ab2d4fd0b983b667abb436435 /docs
parentdb1d1883e00dda67113a2db3d37f9d3c53c23131 (diff)
[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 d3b3eb860dc140c56022704672e7f54fa8a0c648 from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/forms/formsets.txt28
1 files changed, 13 insertions, 15 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index 6e4487f5d9..3368ef4c92 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -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',