6👍
Add humanize to the installed apps in settings.py and load it in the template.
{% load humanize %}
{{ my_num|intcomma }}
- [Django]-Django sitemap http://example.com
- [Django]-User Authentication in Django Rest Framework + Angular.js web app
- [Django]-Django Multiple Choice Field / Checkbox Select Multiple
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.
- [Django]-Why did Django 1.9 replace tuples () with lists [] in settings and URLs?
- [Django]-Can I use Django F() objects with string concatenation?
- [Django]-Django templates: loop through and print all available properties of an object?
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
- [Django]-Django – Get Foreign key objects in single query?
- [Django]-Add rich text format functionality to django TextField
- [Django]-Django filter the model on ManyToMany count?
Source:stackexchange.com