You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to get the voters of an instance. That way I will check in the frontend if has already voted and displayed a UI according to that status.
But getting the review.votes.user_ids() results in additional database hit.
How to get this value without some additional database hits?
I tweaked my app, for now, to use prefetch_related('votes'). But this will still result in a 1-time additional database hit.
I want to avoid that altogether if possible.
The text was updated successfully, but these errors were encountered:
You can use the annotate method, pass in a query set and the current user id, it will return a new query set with is_voted_up and is_voted_down property set on the records you are fetching.
It's still an additional database hit but it's only one hit per query set, not per instance.
I want to get the voters of an instance. That way I will check in the frontend if has already voted and displayed a UI according to that status.
But getting the review.votes.user_ids() results in additional database hit.
How to get this value without some additional database hits?
I tweaked my app, for now, to use prefetch_related('votes'). But this will still result in a 1-time additional database hit.
I want to avoid that altogether if possible.
The text was updated successfully, but these errors were encountered: