数量统计aggregate

Mr.zang's Blog / 2023-05-22 / 原文

比如统计某个会员有多少条留言?

  def follow_num(self):
        num=Guestbook.objects.filter(user=self.pk,status=True).aggregate(c=Count('user__membername'))
        
        return num['c']