Django query - join on the same table

Posted by dana on Stack Overflow See other posts from Stack Overflow or by dana
Published on 2010-06-16T20:31:45Z Indexed on 2010/06/16 20:42 UTC
Read the original article Hit count: 147

Filed under:
|
|
|

i have a mini blog app, and a 'timeline' . there i want to be displayed all the posts from all the friends of a user, plus the posts of that user himself. For that, i have to make some kind of a 'join' between the results of two queries (queries on the same table) , so that the final result will be the combination of the user - posesor of the account, and all his friends. My query looks like this:

blog = New.objects.filter(created_by = following,created_by = request.user)

By that ',' i wanted to make a 'join' -i found something like this on a doc- but this method is not correct- i'm getting an error.

How else could be done this 'join' ? Thanks!

© Stack Overflow or respective owner

Related posts about django

Related posts about query