这是我的模型
class UserAward(models.Model):
user = models.ForeignKey(User, related_name='awards')
award = models.CharField(max_length=255)
week = models.SmallIntegerField(default=0)
year = models.IntegerField(default=0)
points_gained = models.IntegerField(default=0)
timestamp = models.DateTimeField(auto_now=True)
当我给这个时:
users = User.objects.filter(awards__award='level up', awards__week=prev_wk, awards__year=prev_year).order_by('-profiles__level')
我收到此错误:
Related Field has invalid lookup: year
如果我删除filter(awards__year=prev_year)
查询工作正常。
哪里有问题?