[英]How to use dot as thousand separator in Django
In my settings.py
I have following code: 在我的settings.py
我有以下代码:
LANGUAGE_CODE = 'en'
USE_I18N = True
USE_L10N = True
USE_DECIMAL_SEPARATOR = True
DECIMAL_SEPARATOR = ","
USE_THOUSAND_SEPARATOR = True
THOUSAND_SEPARATOR = "."
And in my template I use the number as follows: 在我的模板中,我使用以下数字:
{% load humanize %}
{% load i18n %}
{% load l10n %}
<div>{% trans "Price" %}: € <b>{{ payment|floatformat:2|intcomma }}</b></div>
But still the number is 18,300.00 and I want that it is 18.300,00 . 但仍然是18,300.00 ,我希望它是18.300,00 。
Any idea? 任何想法?
The following is noted in the documentation about DECIMAL_SEPARATOR setting: 关于DECIMAL_SEPARATOR设置的文档中记录了以下内容 :
Default: '.' (Dot)
Default decimal separator used when formatting decimal numbers.
Note that if
USE_L10N
is set toTrue
, then the locale-dictated format has higher precedence and will be applied instead. 请注意,如果USE_L10N
设置为True
,USE_L10N
区域设置指定的格式具有更高的优先级,并且将被应用。
Since USE_L10N
is set, the number format set for the locale is preferred when rendering a number. 由于设置了USE_L10N
,因此在呈现数字时,首选为语言环境设置的数字格式。
As far as I know the current desired format for numbers isn't available in English language locale. 据我所知,当前所需的数字格式在英语语言环境中不可用。 I find that format in used in Deutsch language locale. 我发现该格式在Deutsch语言区域中使用。
The language
template tag allows you to switch language in templates . language
模板标签允许您在模板中切换语言 。
{% load humanize %}
{% load i18n %}
{% load l10n %}
<div>{% trans "Price" %}:
{% language 'de' %}
€ <b>{{ payment|floatformat:2|intcomma }}</b>
{% endlanguage %}
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.