Ticket #11907: 11907.3.diff

File 11907.3.diff, 1.3 KB (added by Chris Beaven, 14 years ago)
  • django/forms/fields.py

    diff --git a/django/forms/fields.py b/django/forms/fields.py
    index 03455e0..51551de 100644
    a b class EmailField(CharField):  
    448448    }
    449449    default_validators = [validators.validate_email]
    450450
     451    def clean(self, value):
     452        value = self.to_python(value).strip()
     453        return super(EmailField, self).clean(value)
     454
    451455class FileField(Field):
    452456    widget = ClearableFileInput
    453457    default_error_messages = {
  • tests/regressiontests/forms/fields.py

    diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py
    index d29e2e8..cf0c3f6 100644
    a b class FieldsTests(TestCase):  
    430430        self.assertEqual(u'', f.clean(''))
    431431        self.assertEqual(u'', f.clean(None))
    432432        self.assertEqual(u'person@example.com', f.clean('person@example.com'))
     433        self.assertEqual(u'example@example.com', f.clean('      example@example.com  \t   \t '))
    433434        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo')
    434435        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@')
    435436        self.assertRaisesErrorWithMessage(ValidationError, "[u'Enter a valid e-mail address.']", f.clean, 'foo@bar')
Back to Top