开发者

Filter related set in a related set

开发者 https://www.devze.com 2023-03-07 14:01 出处:网络
I have the following structure of models : parent Park child Warehouse(foreign key with Park, related_name = park_warehouses)

I have the following structure of models :

parent Park

child Warehouse(foreign key with Park, related_name = park_warehouses)

child chi开发者_开发技巧ld Issue(foreign key with Warehouse, related_name = warehouse_issues)

now I'd like to filter and get amount of Issues for Park by getting issues of each park's building.

I've tried this lambda but it gives me empty array even though I have both issues and buildings for this park selected :

filter(lambda x: park in park.park_warehouses.all(), Issue.objects.all())


Issue.objects.filter(warehouse__park=park)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号