In a Django template, is there a way to convert a float into an integer if and only if it ends in .0?
I have a field for population that is a float in my database. Sometimes it is 'really' a float, ending .5, but more often it ends .0, because there is a whole number of people, and in those cases I'd rather just show an integer.
{{ place.population }} people
Any ideas for a clever way to get round this in Django?
You can use the floatformat filter with a negative argument!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With