开发者

Filter related set in a related set

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜