I have a view that displays posts created by users that actual logged in user follows. It works, by I think the way I've done it isn't good.
BTW, UserProfile is my default user model.
class UserFollower(models.Model): followed = models.OneToOneField(UserProfile, related_name="followed") followers = models.ManyToManyField(UserProfile, related_name="followers", blank=True)
class Post(models.Model): author = models.ForeignKey(settings.AUTH_USER_MODEL) body = models.CharField(max_length=140)
My page view
class MyPage(ListView): model = Post def get_queryset(self): posts =  for user in self.request.user.followers.all(): for post in Post.objects.filter(author=user.followed): posts.append(post) return posts