Opened 18 years ago

Closed 18 years ago

#2366 closed defect (duplicate)

[patch] forms.FloatField is incompatible with models.FloatField

Reported by: adurdin@… 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)

formsFloatField.diff (2.2 KB ) - added by adurdin@… 18 years ago.
Patch

Download all attachments as: .zip

Change History (5)

by adurdin@…, 18 years ago

Attachment: formsFloatField.diff added

Patch

comment:1 by anonymous, 18 years ago

Summary: forms.FloatField is incompatible with models.FloatField[patch] forms.FloatField is incompatible with models.FloatField

comment:2 by anonymous, 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 adurdin@…, 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 adurdin@…, 18 years ago

Resolution: duplicate
Status: newclosed

Closing this -- see #2365 instead, as they are very closely related.

Note: See TracTickets for help on using tickets.
Back to Top