Opened 17 years ago
Closed 17 years ago
#9565 closed (duplicate)
DecimalField damages decimals when saving
| Reported by: | mammique | Owned by: | Karen Tracey |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.0 |
| Severity: | Keywords: | DecimalField precision decimal_places | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Decimals are damaged when using a big value for decimal_places.
Test realized with python-psycopg2 (2.0.6-3) under Ubuntu 8.04.1, on a fresh database and a new project:
class Test(models.Model):
val = models.DecimalField(max_digits=30, decimal_places=18, default=0)
>>> import decimal
>>> Test(val=decimal.Decimal('12.9')).save()
>>> Test.objects.all()[0].val
Decimal("12.900000000000000355")
Change History (2)
comment:1 by , 17 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | assigned → closed |
#5079 already reported this. I'll take a look at fixing the problems noted in the patch that was already posted there.
Note:
See TracTickets
for help on using tickets.
Ugh. django/db/backends/util.py format_number is using float format specifier to format the number to save to the db.