Form clean() method does not trap ValidationError exception
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
class CreateUserForm(forms.Form): username = forms.CharField(max_length=20) email = forms.EmailField() password = forms.CharField(widget=forms.PasswordInput) password2 = forms.CharField(widget=forms.PasswordInput, label="Confirm Password") def clean(self): if self.clean_data.has_key('password') and self.clean_data.has_key('password2'): if self.clean_data['password'] != self.clean_data['password2']: raise ValidationError("The passwords you have entered do not match.") return self.clean_data
When the above form is validated, if both password fields are set but do not match the ValidationError exception does not get caught by BaseForm.full_clean() as I think it should. The ValidationError should make its way into the form level error list, but instead all you get is a traceback.
ValidationError at /users/new/ [u'The passwords you have entered do not match.'] Request Method: POST Request URL: http://localhost:8000/users/new/ Exception Type: ValidationError Exception Value: [u'The passwords you have entered do not match.'] Exception Location: /home/devel/jewel/../jewel/user/views.py in clean, line 32