Home > Back-end >  how do I refer to a QuerySet element in Django?
how do I refer to a QuerySet element in Django?

Time:11-11

I have such a QuerySet:

'category_1': Product.objects.filter(category__slug='white')

how how can I refer to a certain element of this QuerySet? for example, like referring to the elements of a list.

in template:

{{ category_1[1].image.url }}

thanks!

CodePudding user response:

{{ category_1.1.image.url }} Django templates use dot notation, see here.

  • Related