diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2007-03-28 04:31:06 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2007-03-28 04:31:06 +0000 |
| commit | e2b49c379a56730b73d79ec05d6edc790ba08cc9 (patch) | |
| tree | ceae1d5399ba6d1353765ff76d9b62487c2f3741 /django/newforms/forms.py | |
| parent | 132cf258cbdce8bac1d7a3d713c3927f43ead1ed (diff) | |
newforms-admin: Initial implementation of FormSet.
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4836 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/newforms/forms.py')
| -rw-r--r-- | django/newforms/forms.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 2b3aa97428..9c4b2702f6 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -159,6 +159,24 @@ class BaseForm(StrAndUnicode): """ return self.errors.get(NON_FIELD_ERRORS, ErrorList()) + def is_empty(self, exceptions=None): + """ + Returns True if this form has been bound and all fields that aren't + listed in exceptions are empty. + """ + # TODO: This could probably use some optimization + exceptions = exceptions or [] + for name, field in self.fields.items(): + if name in exceptions: + continue + # value_from_datadict() gets the data from the dictionary. + # Each widget type knows how to retrieve its own data, because some + # widgets split data over several HTML fields. + value = field.widget.value_from_datadict(self.data, self.add_prefix(name)) + if value not in (None, ''): + return False + return True + def full_clean(self): """ Cleans all of self.data and populates self.__errors and self.clean_data. |
