From 232b60a21b951bd16b8c95b34fcbcbf3ecd89fca Mon Sep 17 00:00:00 2001 From: David Smith Date: Sun, 12 Feb 2023 13:20:05 +0000 Subject: Refs #32339 -- Updated docs to reflect default
style form rendering in Django 5.0. Follow up to 98756c685ee173bbd43f21ed0553f808be835ce5. --- docs/topics/forms/formsets.txt | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'docs/topics/forms/formsets.txt') diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index d974d72f76..85c35dc2d0 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -33,9 +33,9 @@ in the formset and display them as you would with a regular form: >>> formset = ArticleFormSet() >>> for form in formset: - ... print(form.as_table()) - - + ... print(form) +
+
As you can see it only displayed one empty form. The number of empty forms that is displayed is controlled by the ``extra`` parameter. By default, @@ -77,13 +77,13 @@ example: ... ]) >>> for form in formset: - ... print(form.as_table()) - - - - - - + ... print(form) +
+
+
+
+
+
There are now a total of three forms showing above. One for the initial data that was passed in and two extra forms. Also note that we are passing in a @@ -113,9 +113,9 @@ gives you the ability to limit the number of forms the formset will display: >>> ArticleFormSet = formset_factory(ArticleForm, extra=2, max_num=1) >>> formset = ArticleFormSet() >>> for form in formset: - ... print(form.as_table()) - - + ... print(form) +
+
If the value of ``max_num`` is greater than the number of existing items in the initial data, up to ``extra`` additional blank forms will be added to the @@ -517,16 +517,16 @@ Lets you create a formset with the ability to order: ... {'title': 'Article #2', 'pub_date': datetime.date(2008, 5, 11)}, ... ]) >>> for form in formset: - ... print(form.as_table()) - - - - - - - - - + ... print(form) +
+
+
+
+
+
+
+
+
This adds an additional field to each form. This new field is named ``ORDER`` and is an ``forms.IntegerField``. For the forms that came from the initial @@ -623,16 +623,16 @@ Lets you create a formset with the ability to select forms for deletion: ... {'title': 'Article #2', 'pub_date': datetime.date(2008, 5, 11)}, ... ]) >>> for form in formset: - ... print(form.as_table()) - - - - - - - - - + ... print(form) +
+
+
+
+
+
+
+
+
Similar to ``can_order`` this adds a new field to each form named ``DELETE`` and is a ``forms.BooleanField``. When data comes through marking any of the @@ -755,10 +755,10 @@ fields/attributes of the order and deletion fields: >>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet) >>> formset = ArticleFormSet() >>> for form in formset: - ... print(form.as_table()) - - - + ... print(form) +
+
+
.. _custom-formset-form-kwargs: -- cgit v1.3