how can I output this number in django templates (number of decimal places is variable and I don't know it in advance):
x = 0.000015
1)
{{x}}
output is:
1,5e-05
2)
{{x|stringformat:"f"}}
output is:
0.000015
which is not localized, there should be comma! I need output to be localized and keep all decimal places.
I can't believe that django can't handle such a simple task using built-in tools.
UPDATE: I have correct settings already:
LANGUAGE_CODE = 'ru'
USE_L10N = True
And default Django output works fine for most of float numbers, it only fails on this small number. It outputs with exponent notation, but I need to output as float with all decimal places (number of decimal places is variable).
If you know length of numbers you can try to use floatformat filter:
{{ x|floatformat:6 }}
where 6 is length of decimal part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With