Ticket #5957: 5957-r7000.diff

File 5957-r7000.diff, 1.3 KB (added by Tai Lee <real.human@…>, 17 years ago)

Updated to r7000.

  • django/newforms/fields.py

     
    536536        # will submit for False. Because bool("True") == True, we don't need to
    537537        # handle that explicitly.
    538538        if value == 'False':
    539             return False
     539            value = False
     540        if self.required and not value:
     541            raise ValidationError(self.error_messages['required'])
    540542        return bool(value)
    541543
    542544class NullBooleanField(BooleanField):
  • tests/regressiontests/forms/fields.py

     
    910910>>> f.clean(True)
    911911True
    912912>>> f.clean(False)
    913 False
     913Traceback (most recent call last):
     914...
     915ValidationError: [u'This field is required.']
    914916>>> f.clean(1)
    915917True
    916918>>> f.clean(0)
    917 False
     919Traceback (most recent call last):
     920...
     921ValidationError: [u'This field is required.']
    918922>>> f.clean('Django rocks')
    919923True
    920924
    921925>>> f.clean('True')
    922926True
    923927>>> f.clean('False')
    924 False
     928Traceback (most recent call last):
     929...
     930ValidationError: [u'This field is required.']
    925931
    926932>>> f = BooleanField(required=False)
    927933>>> f.clean('')
Back to Top