Django: Model Get Related Object -
i asked similar question earlier today:
have following, table / class:
class userfriend(model.model): user = models.foreignkey(user, related_name='friend_users' ) friend = models.foreignkey(user, related_name='friend_friends') active = models.booleanfield()
where user built-in auth_user class, want friends, not userfriends object user specific user.
i'm looking following sql:
select u.* auth_user u, user_friend uf u.user_id = 5 , u.id = uf.friend_id , active=1 --- user_id = user being queried..
if user 1 want friends for:
user.friend_users.filter(active=true).values_list('friend', flat=true)
Comments
Post a Comment