二次封装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)

 

posted @ 2022-04-19 19:26  那就凑个整吧  阅读(26)  评论(0编辑  收藏  举报