1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

Fixed #4867. FormSet.is_valid() now returns False when the FormSet is not bound. Thanks John Shaffer.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@6052 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans 2007-09-07 02:32:03 +00:00
parent 976acdc774
commit ff2a2884a1
2 changed files with 7 additions and 1 deletions

View File

@ -153,6 +153,8 @@ class BaseFormSet(object):
return '%s-%s' % (self.prefix, index) return '%s-%s' % (self.prefix, index)
def is_valid(self): def is_valid(self):
if not self.is_bound:
return False
self.full_clean() self.full_clean()
return self._is_valid return self._is_valid

View File

@ -48,6 +48,10 @@ True
>>> formset.cleaned_data >>> formset.cleaned_data
[{'votes': 100, 'choice': u'Calexico'}] [{'votes': 100, 'choice': u'Calexico'}]
If a FormSet was not passed any data, its is_valid method should return False.
>>> formset = ChoiceFormSet()
>>> formset.is_valid()
False
FormSet instances can also have an error attribute if validation failed for FormSet instances can also have an error attribute if validation failed for
any of the forms. any of the forms.