我正在尝试从 api 列出用户并使用 jwt 身份验证,但是当我运行 localhost:8000/api/ 时出现此错误:
_init__() takes 1 positional argument but 2 were given
网址.py:
from django.urls import path,include
from . import views
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
urlpatterns = [
path('api/',views.UserViewSet, name = 'user_list'),
path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]
视图.py:
class UserViewSet(viewsets.ModelViewSet):
queryset = User.object.all()
serializer_class = serializers.UserSerializers