Ticket #5232: decimalfield.diff
File decimalfield.diff, 1.7 KB (added by , 17 years ago) |
---|
-
django/core/validators.py
423 423 except DecimalException: 424 424 raise ValidationError, _("Please enter a valid decimal number.") 425 425 426 pieces = str(val). split('.')426 pieces = str(val).lstrip("-").split('.') 427 427 decimals = (len(pieces) == 2) and len(pieces[1]) or 0 428 428 digits = len(pieces[0]) 429 429 -
django/newforms/fields.py
190 190 value = Decimal(value) 191 191 except DecimalException: 192 192 raise ValidationError(ugettext('Enter a number.')) 193 pieces = str(value). split('.')193 pieces = str(value).lstrip("-").split('.') 194 194 decimals = (len(pieces) == 2) and len(pieces[1]) or 0 195 195 digits = len(pieces[0]) 196 196 if self.max_value is not None and value > self.max_value: -
tests/regressiontests/forms/tests.py
1167 1167 Traceback (most recent call last): 1168 1168 ... 1169 1169 ValidationError: [u'Ensure that there are no more than 2 digits before the decimal point.'] 1170 >>> f.clean('-123.45') 1171 Traceback (most recent call last): 1172 ... 1173 ValidationError: [u'Ensure that there are no more than 4 digits in total.'] 1174 >>> f.clean('-12.34') 1175 Decimal("-12.34") 1170 1176 >>> f = DecimalField(max_digits=4, decimal_places=2, required=False) 1171 1177 >>> f.clean('') 1172 1178