1👍
✅
You can not subscript in Django templates. What you can do is just add an attribute:
def index(request):
queryset = Listing.objects.all()
for listing in queryset:
listing.highest_bid = listing.product_bids.latest('bid')
return render(
request,
'auctions/index.html',
{
'listings': queryset,
},
)
and thus render with:
{{ listing.highest_bid }}
Source:stackexchange.com