2011-05-23 49 views
0

我的模型結構如下:過濾器相關的一組設置

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

現在我想篩選,並通過使每個公園的建設問題得到問題的金額公園。

我已經試過這拉姆達但它給了我,即使我有這個公園選擇了這兩個問題和建築物空數組:

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

回答

1

Issue.objects.filter(warehouse__park=park)

+0

感謝,忘了這一點:) – voxoft 2011-05-23 10:54:01