mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #11418 -- formset.cleaned_data no longer raises AttributeError when is_valid is True. Thanks mlavin!
This also introduces a slightly backwards-incompatible change in FormSet's behavior, see the release docs for details. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14667 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
752bd8bf75
commit
65b380e74a
4 changed files with 93 additions and 13 deletions
|
@ -100,7 +100,12 @@ an ``is_valid`` method on the formset to provide a convenient way to validate
|
|||
all forms in the formset::
|
||||
|
||||
>>> ArticleFormSet = formset_factory(ArticleForm)
|
||||
>>> formset = ArticleFormSet({})
|
||||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': u'1',
|
||||
... 'form-INITIAL_FORMS': u'0',
|
||||
... 'form-MAX_NUM_FORMS': u'',
|
||||
... }
|
||||
>>> formset = ArticleFormSet(data)
|
||||
>>> formset.is_valid()
|
||||
True
|
||||
|
||||
|
@ -113,7 +118,7 @@ provide an invalid article::
|
|||
... 'form-INITIAL_FORMS': u'0',
|
||||
... 'form-MAX_NUM_FORMS': u'',
|
||||
... 'form-0-title': u'Test',
|
||||
... 'form-0-pub_date': u'16 June 1904',
|
||||
... 'form-0-pub_date': u'1904-06-16',
|
||||
... 'form-1-title': u'Test',
|
||||
... 'form-1-pub_date': u'', # <-- this date is missing but required
|
||||
... }
|
||||
|
@ -208,9 +213,9 @@ is where you define your own validation that works at the formset level::
|
|||
... 'form-INITIAL_FORMS': u'0',
|
||||
... 'form-MAX_NUM_FORMS': u'',
|
||||
... 'form-0-title': u'Test',
|
||||
... 'form-0-pub_date': u'16 June 1904',
|
||||
... 'form-0-pub_date': u'1904-06-16',
|
||||
... 'form-1-title': u'Test',
|
||||
... 'form-1-pub_date': u'23 June 1912',
|
||||
... 'form-1-pub_date': u'1912-06-23',
|
||||
... }
|
||||
>>> formset = ArticleFormSet(data)
|
||||
>>> formset.is_valid()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue