CORS_ORIGIN_WHITELIST = [
# 添加黑白名单
'http://172.25.12.63:8080',
]
CORS_ALLOW_CREDENTIALS = True
# 允许的请求方式
CORS_ALLOW_METHODS = [
'*',
]
# 允许的请求头
CORS_ALLOW_HEADERS = [
'*',
]
补充:
此导包自带用户信息字段//
from django.contrib.auth.models import AbstractUser
# 用户模型类 子应用名.模型类
AUTH_USER_MODEL ='myapp.User'
在前段保存token数据//
localStorage.setItem('token',err.data.token)
localStorage.setItem('username',err.data.username)