我的模型有2个十进制字段
class Order (models.Model):
ordered = models.DecimalField(...)
received = models.DecimalField(...)
我需要检索received
小于ordered
的行。
类似的东西:
SELECT * from Order WHERE received < ordered
是否有django语法方式?
答案 0 :(得分:2)
>>> from django.db.models import F
>>> Order.objects.filter(received__lt=F('ordered'))