I have table foo which is related to table bar, how can I make it in Django Orm to use column from related table for filter?
Raw Query:
select a.* from foo as a, bar as b where a.bar_id = b.id and b.is_deleted = 0
Django Orm:
Foo.objects.filter(<bar_is_deleted>=0)
您使用双下划线语法。
Foo.objects.filter(bar__is_deleted=0)
Foo.objects.filter(bar__is_deleted=False)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.