Search code examples
pythondjangojwtdjango-rest-framework-jwt

How can I get jwt payload from request object in my view


I'm using django-rest-framework-jwt in my project. I would like to get user_id from the request object in a view.

I've tried request.user but it returns AnonymousUser.


Solution

  • request.user.user_id
    

    You're just missing the .user_id part of your model user id. You almost had it. Congrats :)