Ticket #4485: decimalfield_null.2.diff
File decimalfield_null.2.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/__init__.py
634 634 _("This value must be a decimal number.")) 635 635 636 636 def _format(self, value): 637 if isinstance(value, basestring) :637 if isinstance(value, basestring) or value is None: 638 638 return value 639 639 else: 640 640 return self.format_number(value) -
tests/regressiontests/model_fields/tests.py
15 15 Traceback (most recent call last): 16 16 ... 17 17 ValidationError: [u'This value must be a decimal number.'] 18 19 >>> f = DecimalField(max_digits=5, decimal_places=1) 20 21 >>> f.get_db_prep_save(2.0) 22 u'2.0' 23 24 >>> f.get_db_prep_save(2.56) 25 u'2.6' 26 27 >>> f.get_db_prep_save(None) 28 29 >>> f.get_db_prep_lookup('exact', 2.0) 30 [u'2.0'] 31 32 >>> f.get_db_prep_lookup('exact', 2.56) 33 [u'2.6'] 34 35 >>> f.get_db_prep_lookup('exact', None) 36 [None] 18 37 """