给出模型:
class Member(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
class MemberAction(models.Model):
member = models.ForeignKey(Member, on_delete=models.CASCADE)
action = models.CharField(max_length=200)
datetime = models.DateTimeField()
points = models.IntegerField()
class MemberMention(models.Model):
member = models.ForeignKey(Member, on_delete=models.CASCADE)
date = models.DateTimeField()
points = models.IntegerField()
我想获得给定一周内MemberAction和MemberMention得分最高的前五名会员。我还希望查询返回给定日期的所有成员的MemberAction行。知道怎么做吗?
我得到了以下代码,但是为points_action
返回的数字不正确。奇怪的是,当我删除对annotate
的{{1}}调用时,它可以正常工作。
points_news