from rest_framework.renderers import JSONRenderer class customrenderer(JSONRenderer): def render(self, data, accepted_media_type=None, renderer_context=None): if renderer_context: if isinstance(data,dict): msg=data.pop("msg",'请求成功') code=data.pop("code",0) else: msg="请求成功" code=0 ret={ 'msg':msg, 'code':code, 'date':data } return super().render(ret,accepted_media_type,renderer_context) else: return super().render(data,accepted_media_type,renderer_context)
celery
最新推荐文章于 2019-09-29 18:53:19 发布