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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think it would be more correct to say those are different representations of the same value ‘5’.
Internally, the value saved (unless you’re actually storing a string) is 5.
When the value is displayed, ie converted to a string representation for the screen, it might be shown as 5, 5.00 or 5.000 but internally, it’s still 5
The two decimal places do not appear (if I can put it that way) until the value is output.
You can’t save a number with 2 decimal places unless you use a string.