Ticket #4390: 4390.diff

File 4390.diff, 841 bytes (added by Gary Wilson <gary.wilson@…>, 17 years ago)

remove data from cleaned_data if a ValidationError was raised.

  • django/newforms/forms.py

    === modified file 'django/newforms/forms.py'
     
    187187                value = field.clean(value)
    188188                self.cleaned_data[name] = value
    189189                if hasattr(self, 'clean_%s' % name):
    190                     value = getattr(self, 'clean_%s' % name)()
    191                 self.cleaned_data[name] = value
     190                    try:
     191                        value = getattr(self, 'clean_%s' % name)()
     192                    except ValidationError:
     193                        del self.cleaned_data[name]
     194                        raise
     195                    else:
     196                        self.cleaned_data[name] = value
    192197            except ValidationError, e:
    193198                errors[name] = e.messages
    194199        try:
Back to Top