Ticket #5957: 5957-r7000.diff
File 5957-r7000.diff, 1.3 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/fields.py
910 910 >>> f.clean(True) 911 911 True 912 912 >>> f.clean(False) 913 False 913 Traceback (most recent call last): 914 ... 915 ValidationError: [u'This field is required.'] 914 916 >>> f.clean(1) 915 917 True 916 918 >>> f.clean(0) 917 False 919 Traceback (most recent call last): 920 ... 921 ValidationError: [u'This field is required.'] 918 922 >>> f.clean('Django rocks') 919 923 True 920 924 921 925 >>> f.clean('True') 922 926 True 923 927 >>> f.clean('False') 924 False 928 Traceback (most recent call last): 929 ... 930 ValidationError: [u'This field is required.'] 925 931 926 932 >>> f = BooleanField(required=False) 927 933 >>> f.clean('')