I am developing a web application that displays an html table using django, django-tables2 and Bootstrap4. I have a column AUM
which contains very large numbers (up to billions). In my models.py
the corresponding model uses a models.Interfield()
for AUM
.
class MyModel(models.Model):
...
AUM = models.IntegerField(null= True, blank= True)
...
Using django-tables2 and Bootstrap4 this model gets transformed into a table and rendered into a template using
{% render_table table %}
The numbers displayed in the corresponding column a displayed in there raw format which looks like e.g. this 1000000000. I want to make it more human readable. I have found two solutions for seperating thousands
- Using
intcomma
fromdjango.contrib.humanize
which is not a viable solution for me as it requires me to add a filter in the template which I cannot do as I am just adding{% render_table table %}
(https://docs.djangoproject.com/en/2.1/ref/contrib/humanize/) - Using the global setting
USE_THOUSAND_SEPARATOR = True
in mysettings.py
which is a solution that works great for me (https://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#use-thousand-separator)
I have also seen that there is something similar to intcomma
which is intword
and it transforms e.g. 1000000 into 1 Million which is in my opinion even more human readable. As with the intcomma
this is not a viable solution for me, which is why I am looking for a global setting like USE_THOUSAND_SEPARATOR = True
however for displaying 1000000 as 1 Million (or Mio.) not 1,000,000.