﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5079	DecimalFields converted to float before being stored	dlangdea@…	Karen Tracey	"If you create the following model:
{{{
class Bug(models.Model):
	field = models.DecimalField(max_digits=40, decimal_places=30)
}}}

The !DecimalField is not being stored in the database correctly as the following code shows:
{{{
>>> b1 = Bug(field=Decimal("".1""))
>>> b1.save()
>>> b1 = Bug.objects.get(id=1)
>>> b1.field
Decimal(""0.100000000000000005551115123126"")
}}}

It seems to work correctly if the following change is made to db.models.fields.!DecimalField.format_number by replacing
{{{
        return u""%.*f"" % (self.decimal_places, value)
}}}

with
{{{
        if isinstance(value, decimal.Decimal):
        	return str(value.quantize(decimal.Decimal("".1"")**self.decimal_places))
        else:
        	return u""%.*f"" % (self.decimal_places, value)
}}}

I'm just starting out, so that fix might not be appropriate.
"		closed	Database layer (models, ORM)	dev		fixed		Erin Kelly richard.davies@…	Accepted	1	0	0	1	0	0
