【发布时间】:2015-04-03 12:54:56
【问题描述】:
这是我的 Django 模型:
from django.db import models
class MyModel(models.Model):
a = models.IntegerField()
b = models.IntegerField()
c = models.IntegerField()
我想检索该模型的所有实例,其中 a = 5 和 b + c > 10。我该怎么做?
当我尝试这个时:
print MyModel.objects.filter(a=5).extra(
select={"total_count": "b + c"},
where=["total_count > 10"],
)
我收到此错误:
OperationalError: (1054, "Unknown column 'total_count' in 'where clause'")
【问题讨论】:
标签: python django orm django-queryset