from rest_framework.response import Response
# 二次封装Response
class APIResponse(Response):
def __init__(self, http_status=0, msg='ok', results=None, status=None,
template_name=None, headers=None,
exception=False, content_type=None, **kwargs):
data = {
'status': http_status,
'msg': msg,
}
if results is not None:
data['result'] = results
data.update(**kwargs)
super().__init__(data=data, status=status,
template_name=template_name, headers=headers,
exception=exception, content_type=content_type)