mirror of
https://github.com/django/django.git
synced 2024-11-22 11:57:34 +01:00
Corrected code-block directives in topics/forms/formsets.txt.
This commit is contained in:
parent
1570ef02f3
commit
2d3531af23
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user