Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的项目中使用 django-rest-framework-jwt。我想从视图中的请求对象中获取 user_id。
我试过request.user了,但它返回 AnonymousUser。
request.user
request.user.user_id
您只是缺少模型用户 ID 的 .user_id 部分。你几乎拥有它。恭喜 :)