diff --git a/django/newforms/forms.py b/django/newforms/forms.py index edd1992cf4..f624e005e9 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -184,8 +184,8 @@ class BaseForm(StrAndUnicode): try: value = field.clean(value) self.clean_data[name] = value - if hasattr(self, 'clean_%s' % name): - value = getattr(self, 'clean_%s' % name)() + if hasattr(self, 'do_clean_%s' % name): + value = getattr(self, 'do_clean_%s' % name)() self.clean_data[name] = value except ValidationError, e: errors[name] = e.messages diff --git a/tests/regressiontests/forms/regressions.py b/tests/regressiontests/forms/regressions.py index 5daabc03af..789ac81715 100644 --- a/tests/regressiontests/forms/regressions.py +++ b/tests/regressiontests/forms/regressions.py @@ -34,4 +34,18 @@ Unicode decoding problems... >>> f = SomeForm() >>> f.as_p() u'

' + +####################### +# Miscellaneous Tests # +####################### + +There once was a problem with Form fields called "data". Let's make sure that +doesn't come back. +>>> class DataForm(Form): +... data = CharField(max_length=10) +>>> f = DataForm({'data': 'xyzzy'}) +>>> f.is_valid() +True +>>> f.clean_data +{'data': u'xyzzy'} """ diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 615cb2247b..82be58dd0c 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -2303,7 +2303,7 @@ returns a list of input. Validation errors are HTML-escaped when output as HTML. >>> class EscapingForm(Form): ... special_name = CharField() -... def clean_special_name(self): +... def do_clean_special_name(self): ... raise ValidationError("Something's wrong with '%s'" % self.clean_data['special_name']) >>> f = EscapingForm({'special_name': "Nothing to escape"}, auto_id=False) @@ -2326,7 +2326,7 @@ including the current field (e.g., the field XXX if you're in clean_XXX()). ... username = CharField(max_length=10) ... password1 = CharField(widget=PasswordInput) ... password2 = CharField(widget=PasswordInput) -... def clean_password2(self): +... def do_clean_password2(self): ... if self.clean_data.get('password1') and self.clean_data.get('password2') and self.clean_data['password1'] != self.clean_data['password2']: ... raise ValidationError(u'Please make sure your passwords match.') ... return self.clean_data['password2']