Opened 17 years ago

Closed 17 years ago

#4211 closed (duplicate)

FloatFields are not actually Floats

Reported by: David Cramer <dcramer@…> Owned by: Jacob
Component: Uncategorized Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

FloatFields should return a float() datatype so they can be used in comparison.

The issue arises when you want to compare data in the database, to data thats not yet in the database.

e.g.

float_field = FloatField(decimal_places=2, max_digits=8)

a = MyModel.objects.get(pk=1)
In [57]: a.unknown3
Out[57]: Decimal("0.00")

In [58]: a.unknown3 == 0
Out[58]: True

In [59]: a.unknown3 == 0.0
Out[59]: False

In [60]: a.unknown3 == 0.00
Out[60]: False

This is misdirection and I believe one of the following should happen:

  • the data type should either be changed to a float
  • the data type should be comparable with a float
  • it should be relabeled DecimalField

Change History (1)

comment:1 by James Bennett, 17 years ago

Resolution: duplicate
Status: newclosed

A more comprehensive discussion is in #2365 (which proposes moving the current FloatField to a different name and implementing a new FloatField which guarantees a Python float type), so I'm closing this as a duplicate.

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