二次封装Response
response.py
from rest_framework.response import Response class APIResponse(Response): def __init__(self, status=100, msg='成功', http_status=None, template_name=None, headers=None, exception=False, content_type=None, **kwargs): data = { 'status': status, 'msg': msg } if kwargs: data.update(kwargs) super().__init__(data=data, status=http_status, template_name=template_name, headers=headers, exception=exception, content_type=content_type)