django rest framework jwt自定义返回值

def jwt_response_payload_handler(token,user=None,request=None):
    """为返回的结果添加用户相关信息"""
    
    return {
             'token':token,
             'user_id':user.id,
             'username':user.username
            }

JWT_AUTH = {
    'JWT_EXPIRATION_DELTA': datetime.timedelta(days=1),  # token有效期
    'JWT_RESPONSE_PAYLOAD_HANDLER': 'users.utils.jwt_response_payload_handler', 
    }

https://blog.csdn.net/weixin_42143049/article/details/82048173

你可能感兴趣的:(django,rest,framework,JWT,django,rest,framework,JWT,django,rest,framework,JWT)