Ich versuche, das intcomma zu verwenden, um meine Nummer in der Vorlage zu formatieren, aber es kann nicht richtig funktionieren.Django number_format funktioniert nicht
{%load humanize%}
{%blocktrans with val=myvalue|intcomma%}The number is {{val}}{%endblocktrans%}
Nach einiger Suche fand ich die django.utils.formats.number_format nicht Funktion ist. Hier ist mein Test:
[email protected]:~$ ./manage.py shell
Python 3.4.4 (default, Feb 17 2016, 02:50:56)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import locale
>>> from django.utils.formats import number_format
>>> val=123456789
>>> number_format(val,force_grouping=True)
'123456789'
>>> locale.getlocale()
('en_US', 'UTF-8')
>>>
Gibt es etwas, das ich falsch eingerichtet habe?
haben Sie versucht '{{val | intcomma}}'? – Leonard2
Haben Sie 'USE_L10N = True' in Ihrem' settings.py'? – Tim