Django â remove trailing zeroes for a Decimal in a template
<p>Is there a way to remove trailing zeros from a <code>Decimal</code> field in a django template? </p>

<p>This is what I have: <code>0.0002559000</code> and this is what I need: <code>0.0002559</code>. </p>

<p>There are answers suggesting to do this using <code>floatformat</code> filter:</p>

<pre><code>{{ balance.bitcoins|floatformat:3 }}
</code></pre>

<p>However, <code>floatformat</code> performs rounding (either down or up), which is unwanted in my case, as I only need to remove trailing zeros without any rounding at all.</p>

<p>The solution is to use <code>normalize()</code> method of a <code>Decimal</code> field:</p>

<pre><code>{{ balance.bitcoins.normalize }}
</code></pre>

python django django-templates