I have created a UserViewSet
in my Django project to get user data via a get request, the viewset should be expecting a bearer type access token in the body. However, when I make the request through postman, it return a error: ValueError: not enough values to unpack (expected 2, got 1)
My UserViewSet
looks like this:
class UserViewSet(viewsets.ModelViewSet):
serializer_class = UserSerializer
permission_classes = (IsAuthenticated,)
def get_object(self):
lookup_field_value = self.kwargs[self.lookup_field]
obj = Account.objects.get(lookup_field_value)
self.check_object_permissions(self.request, obj)
return obj
Now I know it is also expecting me to include a lookup field
in the request, but I have not idea how and where to put it. My lookup field
should be the id
by default, so I just make the request by this endpoint: http://127.0.0.1:8000/account/auth/user/2/
in order to get user data of user id=2
.
Anybody has an idea why I am getting this error, and how to solve it?