[Fixed]-Why django uses a comma as decimal separator

19👍

First of all, I assume you have L10N and I18N turned on in your settings.py, because that’s the default. The difference you see is likely because you are accessing the website from two different computers with two different locales. Django tries to format things for the locale reported by the browser.

However, you can disable this behaviour. See https://docs.djangoproject.com/en/dev/ref/settings/. Set USE_L10N=False, and set the various separator options specified on the linked page.

👤Marcin

30👍

You can use this alternative way directly on your template:

{% load l10n %}

{% localize off %}
{{ my_floatvar }}
{% endlocalize %}

or this one:

{% load l10n %}

{{ my_floatvar|unlocalize }}

More info in https://docs.djangoproject.com/en/dev/topics/i18n/formatting/#controlling-localization-in-templates

Leave a comment