Opened 13 years ago

Closed 12 years ago

#1230 closed defect (invalid)

FloatField values in generated Sql have no standard string representation

Reported by: gp.ciceri@… Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In FloatField class definition there's no value string representation to put the float into the database,

so rounding problems may occur: perhaps a simple helper method like this can help.

def get_db_prep_save(self, value):
        "Returns field's value prepared for saving into a database."
        if self.max_digits == None: self.max_digits = 12
        if self.decimal_places == None: self.decimal_places = 4
        fmt = "%%%s.%sf" % (self.max_digits, self.decimal_places)
        return fmt % value

Thanks for your patience

Change History (1)

comment:1 Changed 12 years ago by Chris Beaven

Resolution: invalid
Status: newclosed

Rounding problems occur even with string formatting in python. Solution is decimal, but that's going around in enough other patches right now that I'm going to just close this one.

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