1👍
✅
If listOfOtherVotes
is a QuerySet
, you can use .select_related(…)
[Django-doc] to make a LEFT OUTER JOIN
in the query, and thus fetch the details of the related .movie
s in the same query, thus avoiding to fetch each .movie
with an extra query:
for otherVote in listOfOtherVotes.select_related('movie'):
# …
movie = otherVote.movie
# …
Source:stackexchange.com