+ 1
How to prevent django orm converting float to integer
If we have a django model called payment with a FloatField named price And we do pm = Payment(price=15.00).save() The results in database is 15 without trailing zeros Is there a way I can keep them? I'm not sure if this problem is actually related to django or mysql itself
1 Antwort
+ 2
I got it. Heres an answer for others with the same problem
Change the FloatField to DecimalField and specify the following options
decimal_places=2
max_digits=10