![](/img/trans.png)
[英]Convert postgres raw query to Django ORM query and group by
[英]Convert raw query to django orm
我在 MySQL 中编写了此查询,但我对将此查询转换为 django orm 感到困惑
SELECT * FROM student.student_data
where created_by in (select user_id from user_profile where user_location in(7, 8));
这可能会帮助你
query = UserProfile.objects.filter(user_location__in = [7,8])
student_data = Student.objects.filter(created_by = query)
更多信息:[https://mattrobenolt.com/the-django-orm-and-subqueries/]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.