Below is the code snippet for iterating over different products to create a dropdown list:
<li
{ % if not category % }class = "selected" {% endif % }>
<a href="{% url "shop:product_list" %}">All</a>
</li>
{% for c in categories %}
<li {% if category.slug == c.slug %}class="selected"{% endif %}>
<a href="{{ c.get_absolute_url }}">{{ c.name }}</a>
</li>
{% endfor %}
It seems that after the 'Books' category, nothing is being displayed in the dropdown list.
I would like to add the following code snippet to the dropdown list:
<li {% if not category %}class="selected"{% endif %}>
<a href="{% url "shop:product_list" %}">All</a>
</li>
{% for c in categories %}
<li {% if category.slug == c.slug %}class="selected"{% endif %}>
<a class="dropdown-item" href="{{ c.get_absolute_url }}">{{ c.name }}</a>
</li>
{% endfor %}
However, the above code snippet is not displaying anything in the dropdown list. Here's the relevant views.py and models.py files for reference.