我有一个像这样的django模型:
class Player(models.Model):
name = models.CharField()
batting = models.IntegerField()
bowling = models.IntegerField()
以下SQL的Django QuerySet相当于什么?
SELECT * FROM player WHERE batting > bowling;
答案 0 :(得分:15)
在django 1.1中,您可以执行以下操作:
players = Player.objects.filter(batting__gt=F('bowling'))
有关详细信息,请参阅other question