Ticket #5957: newforms-booleanfield-required-tests.patch
File newforms-booleanfield-required-tests.patch, 1.1 KB (added by , 17 years ago) |
---|
-
django/newforms/fields.py
536 536 # will submit for False. Because bool("True") == True, we don't need to 537 537 # handle that explicitly. 538 538 if value == 'False': 539 return False 539 value = False 540 if self.required and not value: 541 raise ValidationError(self.error_messages['required']) 540 542 return bool(value) 541 543 542 544 class NullBooleanField(BooleanField): -
tests/regressiontests/forms/tests.py
1694 1694 >>> f.clean(True) 1695 1695 True 1696 1696 >>> f.clean(False) 1697 False 1697 Traceback (most recent call last): 1698 ... 1699 ValidationError: [u'This field is required.'] 1698 1700 >>> f.clean(1) 1699 1701 True 1700 1702 >>> f.clean(0) 1701 False 1703 Traceback (most recent call last): 1704 ... 1705 ValidationError: [u'This field is required.'] 1702 1706 >>> f.clean('Django rocks') 1703 1707 True 1704 1708