Ticket #5903: decimal_field_default_5903.patch
File decimal_field_default_5903.patch, 1.4 KB (added by , 17 years ago) |
---|
-
django/utils/encoding.py
4 4 5 5 from django.utils.functional import Promise 6 6 from django.utils.safestring import SafeData, mark_safe 7 try: 8 import decimal 9 except ImportError: 10 from django.utils import _decimal as decimal # for Python 2.3 7 11 8 12 class DjangoUnicodeDecodeError(UnicodeDecodeError): 9 13 def __init__(self, obj, *args): … … 43 47 44 48 If strings_only is True, don't convert (some) non-string-like objects. 45 49 """ 46 if strings_only and isinstance(s, (types.NoneType, int, long, datetime.datetime, datetime.date, datetime.time, float )):50 if strings_only and isinstance(s, (types.NoneType, int, long, datetime.datetime, datetime.date, datetime.time, float, decimal.Decimal)): 47 51 return s 48 52 try: 49 53 if not isinstance(s, basestring,): -
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 # test default value 20 >>> import decimal 21 >>> f = DecimalField(default=decimal.Decimal("0.00")) 22 >>> f.get_default() 23 Decimal("0.00") 18 24 """