Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i round a value in django template without using the filter

Is there any way that I can do some python math function in django template. Actually I need to round a variable value and I want to achieve this without using the filters.

For example like {{math.round(total)}}.

like image 585
Sakeer Avatar asked Aug 12 '13 11:08

Sakeer


1 Answers

You can use floatformat to round of the value in django template.

{{ total|floatformat }}

If you want to perform more mathematical operations, you can try django-mathfilters. Or you could write your custom template tag and perform the operations in that template tag.

like image 75
arulmr Avatar answered Oct 22 '22 23:10

arulmr