Opened 18 years ago
Closed 18 years ago
#2366 closed defect (duplicate)
[patch] forms.FloatField is incompatible with models.FloatField
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This relates to #2365; models.FloatField uses decimal.Decimal objects, but forms.FloatField uses float() to convert its data to python objects. This causes a loss of accuracy when using high-precision decimals, e.g. models.FloatField(max_digits=30, decimal_places=18): 0.7 entered into the field in the admin interface will be saved as 0.699999999999999956.
Attachments (1)
Change History (5)
by , 18 years ago
Attachment: | formsFloatField.diff added |
---|
comment:1 by , 18 years ago
Summary: | forms.FloatField is incompatible with models.FloatField → [patch] forms.FloatField is incompatible with models.FloatField |
---|
comment:2 by , 18 years ago
A note for when we get to this: If we wanted to go down this route, we would need to start shipping our own copy of the decimal module with Django. It is not in the standard Python library prior to Python 2.4 (and Django is implemented to work with Python 2.3).
comment:3 by , 18 years ago
Would there be any problem with limiting the decimal
dependency to the DecimalField-related bits? That should be straightforward enough.
comment:4 by , 18 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Closing this -- see #2365 instead, as they are very closely related.
Patch