0

I've the template as follows:

<h2>Coupon<b class="font40">{{ coupon.cash|floatformat:"0" }}</b>.00</h2>

I can get the integer part with 'floatformat'. How can I get the fractional part with Django template? (e.g. the fractional part of '8.5' is '5') Thanks.

user1179442
  • 473
  • 5
  • 16

1 Answers1

1

I think your best choice is to create your own filter, or to reduce processing in your templates, calculate the remainder in the view and pass it to the template as a specific field?

Theres a good question here with some methods for the actual extraction of the digits within your filter (if you choose that method).

Community
  • 1
  • 1
srowland
  • 1,625
  • 1
  • 12
  • 19