I am currently utilizing the Django framework for my project. I have implemented a CSS that applies a ribbon to an image, but I only want this ribbon to appear on certain images stored in the database. Within the HTML file for displaying product details, I have written the following code snippet:
{% if product.get_image_url %}
<div class="ribbon-wrapper-orange"><div class="ribbon-orange">{{ product.duration }}</div></div>
<a href='{{ product.get_absolute_url }}'><img id='img' src='{{ product.get_image_url }}' class='img-responsive' /></a>
{% endif %}
While the above code works properly when there is a time duration specified in the database, it presents an issue when no duration is provided - an empty ribbon still appears on the image. Any suggestions on how I can ensure that the ribbon only shows up on images with a time duration specified in the product field?