Created
August 27, 2020 19:58
-
-
Save mentix02/d9b9b26322128fc0fddcc3ade61d0e7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FeedAPIView(ListAPIView): | |
serializer_class = PostSerializer | |
permission_classes = (IsAuthenticated,) | |
def get_queryset(self) -> QuerySet: | |
user = self.request.user | |
followers = user.following | |
follower_ids = list(followers.values_list('id', flat=True)) + [user.id] | |
return Post.objects.filter(user__in=follower_ids).order_by('-timestamp') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment