如何在Django中选择COUNT(*)GROUP BY和ORDER BY?
我正在使用事务处理模型来跟踪通过系统的所有事件 class Transaction(models.Model): actor = models.ForeignKey(User, related_name="actor") acted = models.ForeignKey(User, related_name="acted", null=True, blank=True) action_id = models.IntegerField() ...... 如何获得系统中的前5名演员? 在SQL中,基本上 SELECT actor, COUNT(*) as total FROM Transaction GROUP BY actor ORDER BY total DESC