Answer the question
In order to leave comments, you need to log in
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.
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question