Answer the question
In order to leave comments, you need to log in
Django float output, how right?
In template, all float numbers are displayed separated by a comma :), and not by a dot. Why is that?
How to display a floating point number with a dot?
I also don’t understand how to display a floating point number only, then what is after the point? For example 1234.567 output 567
Answer the question
In order to leave comments, you need to log in
Found the best solution without various filters and extra code: USE_L10N
Read here djbook.ru/rel1.7/topics/i18n/formatting.html
The filter can be used.
https://docs.djangoproject.com/en/1.7/howto/custom...
from django.template.defaultfilters import floatformat
from django.template import Library
register = Library()
def formatted_float(value):
value = floatformat(value, arg=4)
return str(value).replace(',', '.')
register.filter('formatted_float', formatted_float)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question