Python/Django: If 5 and 5.00 are different values (when expressed in Decimal), then
You have an argument that Django ought to enforce a certain precision on its Python objects, but decimal_places is probably more about maximum precision. I believe precision is not stored in the database, so it will be lost in any case.
In any case, if you want to enforce precision, use something like: Decimal(5).quantize(Decimal(10)**-DECIMAL_PLACES)
You can overload the to_python method in a custom django.db.models.DecimalField to ensure that a python Decimal object with the correct precision is returned.
If 5 and 5.00 and 5.000 are all different, then why does Django's decimal field save without the .00 even when I have decimal_places=2
?
More importantly, how can I save a value 5.00 as 5.00 in Django without using String.