Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG in https://github.com/yibeibaoke/InstaDemo/blob/master/Insta/views.py#L20-L25 #3

Open
daidai21 opened this issue Dec 29, 2019 · 0 comments

Comments

@daidai21
Copy link

daidai21 commented Dec 29, 2019

InstaDemo/Insta/views.py

Lines 20 to 25 in 79d55e1

def get_queryset(self):
current_user = self.request.user
following = set()
for conn in UserConnection.objects.filter(creator=current_user).select_related('following'):
following.add(conn.following)
return Post.objects.filter(author__in=following)

should change to:

    def get_queryset(self):
        if not self.request.user.is_authenticated:
            return 

        current_user = self.request.user
        following = set()
        for conn in UserConnection.objects.filter(creator=current_user).select_related('following'):
            following.add(conn.following)
        return Post.objects.filter(author__in=following)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant