我有稱爲'has_location'和'地點'的表。 'has_location'有user_has
和location_id
及其自己的id
,它由django自己給出。django模型對象過濾器
'地點'有更多列。
現在我想獲得某個用戶的所有位置。我所做的是..(user.id是已知的):
users_locations_id = has_location.objects.filter(user_has__exact=user.id)
locations = Location.objects.filter(id__in=users_locations_id)
print len(locations)
,但我爲此print
越來越0
。我有數據在分貝。但我有感覺__in
不接受模特身份證,是嗎?
謝謝
您能向我們展示這三個模型定義的相關部分嗎? – 2013-03-26 12:01:24
@GarethRees,當然,但他們只是一個正常的模型。我認爲,這裏的重點是關於我可以使用'__in''的更多信息。 – doniyor 2013-03-26 12:03:48