一、下载 djangorestframework-simplejwt
pip install djangorestframework-simplejwt
二、settings文件增加配置
setting.py
用户model添加方框中的内容: 增加is_authenticated方法
三、新建文件
文件里写入下面代码,代码中的用户模型model改为自己的,我的模型叫User。
from rest_framework_simplejwt.authentication import JWTAuthentication
from rest_framework_simplejwt.exceptions import InvalidToken, AuthenticationFailed
from rest_framework_simplejwt.serializers import TokenObtainPa