【发布时间】:2021-12-21 08:58:58
【问题描述】:
我是 Django Restframework 的新手。我使用 JWT 进行登录,注册 API,一切正常,我想获取经过身份验证(令牌)的用户信息。这是我的 UserViewSet 代码
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
authentication_classes = [IsAuthenticated,]
我在 Postman 上测试过,但收到:“'IsAuthenticated' 对象没有属性 'authenticate'”
REST_FRAMEWORK = {
'NONE_FIELD_ERRORS_KEY':'error',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
}
您能帮我解决这个问题吗?非常感谢。
【问题讨论】:
标签: django django-rest-framework django-views django-rest-framework-jwt django-rest-framework-simplejwt