django - object filter logic

Andross01

New Member
i am stuck in this state: i have locations table in db. and i also have rating table, which contains rating of each location referencing by the id of each location. now i want to get the first 5 locations and its rating. so i have to touch 2 tables now: locations and rating. i did this: \[code\]all_locations = Locations.objects.all()[:5]all_ratings = Rating.objects.filter(of_location=all_locations.id)\[/code\]but this seems to be wrong because \[code\]all_locations\[/code\] is a queryset containing 5 locations and not one location, so it has 5 different ids. but how can i achieve this goal?: take 5 locations and ratings of each of these 5 locations.
 
Back
Top