Django

Code

Ticket #2366 (closed: duplicate)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: adurdin@gmail.com Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

formsFloatField.diff (2.2 kB) - added by adurdin@gmail.com on 07/17/06 04:14:23.
Patch

Change History

07/17/06 04:14:23 changed by adurdin@gmail.com

  • attachment formsFloatField.diff added.

Patch

07/17/06 05:12:30 changed by anonymous

  • summary changed from forms.FloatField is incompatible with models.FloatField to [patch] forms.FloatField is incompatible with models.FloatField.

07/18/06 21:14:55 changed by anonymous

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).

07/19/06 10:30:33 changed by adurdin@gmail.com

Would there be any problem with limiting the decimal dependency to the DecimalField?-related bits? That should be straightforward enough.

08/01/06 08:55:43 changed by adurdin@gmail.com

  • status changed from new to closed.
  • resolution set to duplicate.

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


Add/Change #2366 ([patch] forms.FloatField is incompatible with models.FloatField)




Change Properties
Action