Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #4297 -- Made form errors available to sub-classes. Thanks, Gar…

…y Wilson.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5347 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1c42c7cade2cfe970dad844d00d7f5b9fa3e5205 1 parent 198127a
@malcolmt malcolmt authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 django/newforms/forms.py
View
17 django/newforms/forms.py
@@ -63,7 +63,7 @@ def __init__(self, data=None, auto_id='id_%s', prefix=None, initial=None):
self.auto_id = auto_id
self.prefix = prefix
self.initial = initial or {}
- self.__errors = None # Stores the errors after clean() has been called.
+ self._errors = None # Stores the errors after clean() has been called.
# The base_fields class attribute is the *class-wide* definition of
# fields. Because a particular *instance* of the class might want to
@@ -87,12 +87,12 @@ def __getitem__(self, name):
raise KeyError('Key %r not found in Form' % name)
return BoundField(self, field, name)
- def _errors(self):
+ def _get_errors(self):
"Returns an ErrorDict for self.data"
- if self.__errors is None:
+ if self._errors is None:
self.full_clean()
- return self.__errors
- errors = property(_errors)
+ return self._errors
+ errors = property(_get_errors)
def is_valid(self):
"""
@@ -171,11 +171,12 @@ def non_field_errors(self):
def full_clean(self):
"""
- Cleans all of self.data and populates self.__errors and self.cleaned_data.
+ Cleans all of self.data and populates self._errors and
+ self.cleaned_data.
"""
errors = ErrorDict()
if not self.is_bound: # Stop further processing.
- self.__errors = errors
+ self._errors = errors
return
self.cleaned_data = {}
for name, field in self.fields.items():
@@ -199,7 +200,7 @@ def full_clean(self):
errors[NON_FIELD_ERRORS] = e.messages
if errors:
delattr(self, 'cleaned_data')
- self.__errors = errors
+ self._errors = errors
def clean(self):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.