djangosnippets.org: Latest snippets tagged with 'mega'https://djangosnippets.org/tags/mega/2015-08-04T02:07:20.194108-05:00Django filter for shrinking [big] numbers
2015-08-04T02:07:20.194108-05:00pedromagnushttps://djangosnippets.org/snippets/10520/<p>Simple filter that shrinks [big] numbers sufixing "M" for numbers bigger than million, or "K" for numbers bigger than thousand.
It does a division over the number before converting to string so rounding is properly done.</p>
<p>Examples:</p>
<p><code>{{ 123456|shrink_num }} >> 123.6K</code></p>
<p><code>{{ 1234567|shrink_num }} >> 1.2M</code></p>
Freely redistributable