M
M
Mike2018-10-18 01:19:22
Django
Mike, 2018-10-18 01:19:22

How to get a user profile with the ability to edit?

I have a UserPrfile model. I'm trying to get a current user's profile and then be able to edit it. I make a simple GET request and get

ValueError: Cannot query "mikefromru": Must be "User" instance.

views.py
class GET_SOMETHING(viewsets.ModelViewSet):
    queryset = UserProfile.objects.all()
    serializer_class = UserProfileSerializer 

    def get_queryset(self):
        if self.action == 'list':
            return self.queryset.filter(user=self.request.user.userprofile)
        return self.queryset

How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question