Reputation: 852
I am using Django sample JWT and I already set up for the login user. let say now I have a login user token. but at the client-side, we still need to show like user name, user image, and email address. How to get this information in the client-side?
I created a new method that will return current login user at backend=>
#get token for login user
@action(detail=False, methods=['get'])
def get_current_user(self,request):
data = {}
data["username"] = request.user.username
.
.
.
return Response({format(data)})
It's the correct way? or Can I serialize request.user
and return directly? Is there any serializer for Auth-User? I am stuck there. Thanks.
Upvotes: 0
Views: 174
Reputation: 28
If you are going for a basic retrieve of the user,you should create a serializer for the user and a generic view which uses that serializer to return the data
Upvotes: 0