I\'m trying to format numbers. Examples:
1 => 1
12 => 12
123 => 123
1234 => 1,234
12345 => 12,345
It strikes as a
Slightly off topic:
I found this question while looking for a way to format a number as currency, like so:
$100
($50) # negative numbers without '-' and in parens
I ended up doing:
{% if var >= 0 %} ${{ var|stringformat:"d" }}
{% elif var < 0 %} $({{ var|stringformat:"d"|cut:"-" }})
{% endif %}
You could also do, e.g. {{ var|stringformat:"1.2f"|cut:"-" }} to display as $50.00 (with 2 decimal places if that's what you want.
Perhaps slightly on the hacky side, but maybe someone else will find it useful.