Django template: show price normally, or show discount price with original price struck through below

I’m building a product card in a Django template. I want this behavior:

  • If discount_price is 0, show only price.

  • If discount_price is not 0, show discount_price on top and the original price below it with a strike-through.

Here is my current template

<div class="flex flex-col">
    {% if products.discount_price == 00.00 %}
        <span class="font-bold">GH₵{{products.price}}</span>
    {% else %}
        <span class="line-through">GH₵{{products.discount_price}}</span>
    {% endif %}
</div>
Вернуться на верх