[Fixed]-Django-DRF See all posts from friends

1👍

✅

This may get you started,

So what you need to do first is get all the friends, you can do that by using

friends = <user_objects>.Friendship_set.all()

Read more about is here.

Now that you have all the friends of that particular user, covert their IDs to list and use the in list filter.

Post.objects.filter(poster__id__in=[list_of_ids_of_friends])

See this answer for filtering on foreign key properties.

Leave a comment