我有以下模型:
class P (models.Model):
title = models.CharField(max_length=100)
votes_up = models.ManyToManyField(User)
votes_down = models.ManyToManyField(User)
有没有办法做类似的事情
P.objects.annotate(rating = Count(votes_up) - Count(votes_down)).order_by('-rating')
?