Vitalii Bashynskyi
Vitalii Bashynskyi

Reputation: 45

how do I refer to a QuerySet element in Django?

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!

Upvotes: 1

Views: 180

Answers (1)

TaipanRex
TaipanRex

Reputation: 820

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

Upvotes: 2

Related Questions