torchbox/wagtail-experiments

Floats are being formatted in a language aware manner

mitchellslager opened this issue · 0 comments

The following line of code (in report.html) does not format floats correctly in some languages:
'{{ history_entry.conversion_rate|floatformat:2|escapejs }}'{% if not forloop.last %},{% endif %}

For example, in my Dutch language based Django site this will format 12.3456 as 12,35. This breaks the report graph.

I think the solution is to change that line of code to:
'{{ history_entry.conversion_rate|stringformat:".2f"|escapejs }}'{% if not forloop.last %},{% endif %}