I want to round off my decimal values as below:
7,715.625 becomes 7,716
How do I achieve this?
I want to round off my decimal values as below:
7,715.625 becomes 7,716
How do I achieve this?
If you don't care about the commas, then floatformat
will do the job:
{{ value|floatformat:"0" }}
If you do care about commas, you want:
{{ value|floatformat:"0"|intcomma }}
(Hat tip to Stephen for pointing me at intcomma
!)
To use 'intcomma' filter, you should add 'django.contrib.humanize' to your INSTALLED_APPS setting and {% load humanize %} in a template.