目录
官网文档
https://django-rest-framework-simplejwt.readthedocs.io/en/latest/
安装
bash
pip install djangorestframework-simplejwt
项目配置
bash
REST_FRAMEWORK = {
...
'DEFAULT_AUTHENTICATION_CLASSES': (
...
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
...
}
拓展配置
bash
# JWT扩展配置
import datetime
JWT_AUTH = {
# 设置生成jwt token的有效时间
'JWT_EXPIRATION_DELTA': datetime.timedelta(days=7),
}