From 54a0849ebd78a7ec9aab39d0fadc0dfbee489bed Mon Sep 17 00:00:00 2001 From: antoliny0919 Date: Fri, 15 Nov 2024 18:31:44 +0900 Subject: [PATCH] Updated can_order, can_delete example from Formsets docs. --- docs/topics/forms/formsets.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index 3b68ed614c..855a8f0498 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -571,14 +571,12 @@ happen when the user changes these values: ... {"title": "Article #2", "pub_date": datetime.date(2008, 5, 11)}, ... ], ... ) - >>> formset.is_valid() - True >>> for form in formset.ordered_forms: ... print(form.cleaned_data) ... - {'pub_date': datetime.date(2008, 5, 1), 'ORDER': 0, 'title': 'Article #3'} - {'pub_date': datetime.date(2008, 5, 11), 'ORDER': 1, 'title': 'Article #2'} - {'pub_date': datetime.date(2008, 5, 10), 'ORDER': 2, 'title': 'Article #1'} + {'title': 'Article #3', 'pub_date': datetime.date(2008, 5, 1), 'ORDER': 0} + {'title': 'Article #2', 'pub_date': datetime.date(2008, 5, 11), 'ORDER': 1} + {'title': 'Article #1', 'pub_date': datetime.date(2008, 5, 10), 'ORDER': 2} :class:`~django.forms.formsets.BaseFormSet` also provides an :attr:`~django.forms.formsets.BaseFormSet.ordering_widget` attribute and @@ -690,7 +688,7 @@ delete fields you can access them with ``deleted_forms``: ... ], ... ) >>> [form.cleaned_data for form in formset.deleted_forms] - [{'DELETE': True, 'pub_date': datetime.date(2008, 5, 10), 'title': 'Article #1'}] + [{'title': 'Article #1', 'pub_date': datetime.date(2008, 5, 10), 'DELETE': True}] If you are using a :class:`ModelFormSet`, model instances for deleted forms will be deleted when you call