> As an aside, this can probably be written as: 
>
>   current_user_vote = item.vote_set.filter(user=request.user) 
>
> > 
> > I tried to use annotate() two times, however it filtered out everything 
> > except items current user voted on. 
>
> Just use it once. 
>

Thank you for answer, however I still can't see how can I do it.

Using annotate only once won't let me use filter() to exclude users 
different than the current one.

Item.objects.annotate(
    score=Sum('votes__value'),
    current_user_vote=Sum('votes__value')
)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/38b52a30-b731-4eb6-b36c-550911638a87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to