user2169287
user2169287

Reputation: 211

Remove the decimal part of a floating-point number in django?

I have a variable called {{value.item_total }} which is 499.00, but I want to remove the decimal points for this value in my templates file to make it 499. How could I do this?

Upvotes: 3

Views: 11375

Answers (3)

bofh
bofh

Reputation: 136

you have to use Built-in template tags and filters (https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#get-digit). In your case use

{{ value.item_total|floatformat:"0" }}

Thats it.

Greetings

Upvotes: 10

catherine
catherine

Reputation: 22808

 {{value.item_total|floatformat }}

Upvotes: 1

astorije
astorije

Reputation: 2707

Seen here:

You can use the floatformat filter with a negative argument!

The answer would be:

{{ value.item_total|floatformat }}

Upvotes: 18

Related Questions