Save py2.6 from Decimal Float fun

This commit is contained in:
Ross Lawley 2013-04-26 08:43:38 +00:00
parent 5e94637adc
commit 13d8dfdb5f

View File

@ -297,8 +297,9 @@ class DecimalField(BaseField):
if value is None: if value is None:
return value return value
return decimal.Decimal(value).quantize(self.precision, # Convert to string for python 2.6 before casting to Decimal
rounding=self.rounding) value = decimal.Decimal("%s" % value)
return value.quantize(self.precision, rounding=self.rounding)
def to_mongo(self, value): def to_mongo(self, value):
if value is None: if value is None: