Ticket #3482: 4490.diff

File 4490.diff, 941 bytes (added by Jeff Bauer <jbauer@…>, 8 years ago)
  • django/newforms/fields.py

     
    373373            raise ValidationError(gettext(u'This field is required.'))
    374374        elif not self.required and not value:
    375375            return []
     376        elif not self.required and len(value) == 1 and not value[0]:
     377            return value
    376378        if not isinstance(value, (list, tuple)):
    377379            raise ValidationError(gettext(u'Enter a list of values.'))
    378380        new_value = []
  • tests/regressiontests/forms/tests.py

     
    15741574[]
    15751575>>> f.clean(None)
    15761576[]
     1577>>> f.clean([''])
     1578['']
    15771579>>> f.clean([1])
    15781580[u'1']
    15791581>>> f.clean(['1'])
Back to Top