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)
精彩评论