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 ++++++++++++++++++++-------------------- docs/topics/forms/modelforms.txt | 16 ++++----- 2 files changed, 45 insertions(+), 45 deletions(-) (limited to 'docs/topics/forms') 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: diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index 4242cd96e0..be871fd4b0 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -815,13 +815,13 @@ with the ``Author`` model. It works just like a regular formset: >>> formset = AuthorFormSet() >>> print(formset) - -
+
+
.. note:: @@ -1021,11 +1021,11 @@ so long as the total number of forms does not exceed ``max_num``: >>> AuthorFormSet = modelformset_factory(Author, fields=['name'], max_num=4, extra=2) >>> formset = AuthorFormSet(queryset=Author.objects.order_by('name')) >>> for form in formset: - ... print(form.as_table()) - - - - + ... print(form) +
+
+
+
A ``max_num`` value of ``None`` (the default) puts a high limit on the number of forms displayed (1000). In practice this is equivalent to no limit. -- cgit v1.3