次のような「ダイアログ」のマネージャーがあります。
class AnnotationManager(models.Manager):
def get_query_set(self):
return super(AnnotationManager, self).get_query_set().annotate(
num_votes=Count('vote', distinct=True),
num_comments=Count('comment', distinct=True),
num_commentators = Count('comment__user', distinct=True),
)
投票とコメントには、Dialog への ForeignKey があります。コメントには、ユーザーへの ForeignKey があります。私がこれを行うとき:
dialogs_queryset = Dialog.public.filter(organization=organization)
dialogs_popularity = dialogs_queryset.exclude(num_comments=0) | dialogs_queryset.exclude(num_votes=0)
...dialogs_popularity は組み合わせを返すことはありませんが、コメントが 0 件を超えるダイアログのみ、または OR の順序を変更すると、投票数が 0 件を超えるダイアログのみが返されます!
私にとって、予想される動作は、0 票を超えるダイアログと 0 を超えるコメントを含むダイアログを取得することです。
私は何が欠けていますか?または、ここで注釈の動作にバグがありますか?