From 3960bec41baadd425ee8e1173050c7d2c9e031f5 Mon Sep 17 00:00:00 2001 From: Mitchina Date: Fri, 8 Mar 2024 07:10:36 +0100 Subject: [PATCH] [5.0.x] Corrected code-block directives in topics/forms/formsets.txt. Backport of 2d3531af234c4bc2b78f8b3d8e916ec3ac33fb24 from main --- docs/topics/forms/formsets.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index d09a1a063f..1f49044e6e 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -432,16 +432,18 @@ If ``validate_max=True`` is passed to that the number of forms in the data set, minus those marked for deletion, is less than or equal to ``max_num``. +.. code-block:: pycon + >>> from django.forms import formset_factory >>> from myapp.forms import ArticleForm >>> ArticleFormSet = formset_factory(ArticleForm, max_num=1, validate_max=True) >>> data = { - ... 'form-TOTAL_FORMS': '2', - ... 'form-INITIAL_FORMS': '0', - ... 'form-0-title': 'Test', - ... 'form-0-pub_date': '1904-06-16', - ... 'form-1-title': 'Test 2', - ... 'form-1-pub_date': '1912-06-23', + ... "form-TOTAL_FORMS": "2", + ... "form-INITIAL_FORMS": "0", + ... "form-0-title": "Test", + ... "form-0-pub_date": "1904-06-16", + ... "form-1-title": "Test 2", + ... "form-1-pub_date": "1912-06-23", ... } >>> formset = ArticleFormSet(data) >>> formset.is_valid() @@ -475,16 +477,18 @@ If ``validate_min=True`` is passed to that the number of forms in the data set, minus those marked for deletion, is greater than or equal to ``min_num``. +.. code-block:: pycon + >>> from django.forms import formset_factory >>> from myapp.forms import ArticleForm >>> ArticleFormSet = formset_factory(ArticleForm, min_num=3, validate_min=True) >>> data = { - ... 'form-TOTAL_FORMS': '2', - ... 'form-INITIAL_FORMS': '0', - ... 'form-0-title': 'Test', - ... 'form-0-pub_date': '1904-06-16', - ... 'form-1-title': 'Test 2', - ... 'form-1-pub_date': '1912-06-23', + ... "form-TOTAL_FORMS": "2", + ... "form-INITIAL_FORMS": "0", + ... "form-0-title": "Test", + ... "form-0-pub_date": "1904-06-16", + ... "form-1-title": "Test 2", + ... "form-1-pub_date": "1912-06-23", ... } >>> formset = ArticleFormSet(data) >>> formset.is_valid()