i just can't seem to find a definitive answer to this issue, and django's irc needs auth to services... So my question is : how can you force some kind of formatting for FloatFields in template when you're using Django ?
The problem is simple i need simple dot separated numbers like this : 42547.34 And i end up with comma separated values...
here is a example of template where the problem occurs :
{% for point in zone.points.all %} {% if forloop.last %} new google.maps.LatLng({{point.latitude|floatformat}},{{point.longitude|floatformat}}) {% else %} new google.maps.LatLng({{point.latitude|floatformat}},{{point.longitude|floatformat}}), {% endif %} {% endfor %}];
Thank you for your time.
P.S. i don't have this problem when using the admin generated forms where the floats appear correctly (My locale is en_US)
What does {{ name }} this mean in Django Templates? {{ name }} will be the output. It will be displayed as name in HTML. The name will be replaced with values of Python variable.
autoescape. Controls the current auto-escaping behavior. This tag takes either on or off as an argument and that determines whether auto-escaping is in effect inside the block. The block is closed with an endautoescape ending tag.
To comment-out part of a line in a template, use the comment syntax: {# #} . This syntax can only be used for single-line comments (no newlines are permitted between the {# and #} delimiters). If you need to comment out a multiline portion of the template, see the comment tag.
{{ float_var|stringformat:"f" }}
You can now force the value to be printed without localization.
{% load l10n %} {{ value|unlocalize }}
Taken from https://docs.djangoproject.com/en/2.2/topics/i18n/formatting/#std:templatefilter-unlocalize
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