[Django]-Django separate thousands in template

37👍

You can use the intcomma filter.

👤sykora

6👍

Add humanize to the installed apps in settings.py and load it in the template.

{% load humanize %}
{{ my_num|intcomma }}

4👍

One easy way is to import locale and do the formatting in your view function.

Even easier to read this: http://docs.djangoproject.com/en/dev/topics/i18n/#overview

For format localization, it’s just
necessary to set USE_L10N = True in
your settings file. If USE_L10N is set
to True, Django will display numbers
and dates in the format of the current
locale. That includes field
representation on templates, and
allowed input formats on the admin.

👤S.Lott

3👍

You could add the following to settings.py:

USE_THOUSAND_SEPARATOR = True

That should work and you don’t have to act with loading stuff.
https://docs.djangoproject.com/en/4.1/ref/settings/#use-thousand-separator

👤Gunnar

Leave a comment