from rest_framework.response import Response class APIResponse(Response): def __init__ (self, data_status, msg, results=None, headers=None, status=None, ** kwargs): ‘‘‘ :param data_status: 状态码 :param msg: 提示信息 :param res
from rest_framework.response import Response class APIResponse(Response): def __init__(self, data_status, msg, results=None, headers=None, status=None, **kwargs): ‘‘‘ :param data_status: 状态码 :param msg: 提示信息 :param results: 附加信息,如序列化得到的数据 :param headers: :param status: HTTP状态码 :param kwargs: 其他信息 ‘‘‘ data = { ‘status‘: data_status, ‘msg‘: msg, } if results: data[‘results‘] = results data.update(kwargs) super().__init__(data=data, headers=headers, status=status)