相关疑难解决方法(0)

如何在django的queryset中查询子查询?

我怎么能在django的查询集中有一个子查询?例如,如果我有:

select name, age from person, employee where person.id = employee.id and
employee.id in (select id from employee where employee.company = 'Private')
Run Code Online (Sandbox Code Playgroud)

这就是我所做的.

Person.objects.value('name', 'age')
Employee.objects.filter(company='Private')
Run Code Online (Sandbox Code Playgroud)

但它没有工作,因为它返回两个输出...

python django

28
推荐指数
4
解决办法
3万
查看次数

标签 统计

django ×1

python ×1