[Answered ]-ListView in Django

1πŸ‘

βœ…

In your code use product.category.title like so:

...
    {% if product.category.title == 'Bags' %}
...

You are comparing a Category object with the string Bags.

//edit

I also recommend filtering the data in the view, if you only need that data in the view. There is no need to fetch all the products from your database and send them to the view, just to render a portion of it.

πŸ‘€SvenTUM

Leave a comment