一、生成token并返回 import jwt import datetime user = User.objects.filter(id=userid) if user: payload = { 'exp':datetime.datetime.utconutcnow() + datetime.timedelta(days=1), 'data':{ 'userid':user.userid, } } # 生成token token = jwt.