添加到app列表
INSTALLED_APPS = (...'rest_framework_simplejwt.token_blacklist',...)
执行迁移
python manage.py migrate
重写logout视图
rom rest_framework_simplejwt.tokens import RefreshTokenclass BlacklistRefreshView(APIView):def post(self, request)token = RefreshToken(request.data.get('refresh'))token.blacklist()return Response("Success")
在urls.py上注册视图
path('/api/logout', views.BlacklistRefreshView.as_view(), name="logout"),
