当前位置:网站首页>DRF --- response rewrite
DRF --- response rewrite
2022-07-01 17:32:00 【I'm not big head】
# response_expestion.py
from rest_framework.views import exception_handler
from rest_framework import status
from rest_framework.response import Response
class APIResponse(Response):
def __init__(self, result=None, code=None, msg=' success ', status=None, headers=None, content_type=None, **kwargs):
dic = {
'code': code,
'msg': msg
}
if result:
dic['result'] = result
else:
dic.update(kwargs)
super().__init__(data=dict, status=status, headers=headers, content_type=None)
边栏推荐
猜你喜欢

Intelligent operation and maintenance practice: banking business process and single transaction tracking

Pytest learning notes (13) -allure of allure Description () and @allure title()

PETRv2:一个多摄像头图像3D感知的统一框架

美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告

重磅披露!上百个重要信息系统被入侵,主机成为重点攻击目标

【Try to Hack】vulnhub DC4

Detailed explanation of string's trim() and substring()

DNS

The amazing open source animation library is not only awesome, but also small

String class
随机推荐
Oom caused by improper use of multithreading
[Verilog quick start of Niuke network question brushing series] ~ priority encoder circuit ①
How to write good code - Defensive Programming Guide
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
ShenYu 网关开发:在本地启用运行
【Try to Hack】vulnhub DC4
Is it safe to open an ETF account online? What are the steps?
Replace UUID, nanoid is faster and safer!
机器学习11-聚类,孤立点判别
Maizeer: the two batches of products reported by the media have been taken off the shelves and sealed, and consumer appeals are accepted
Research Report on development prediction and investment direction of nylon filament sewing thread in China (2022 Edition)
Machine learning 11 clustering, outlier discrimination
National Security Agency (NSA) "sour Fox" vulnerability attack weapon platform technical analysis report
【C补充】【字符串】按日期排序显示一个月的日程
中国酶制剂市场预测与投资战略研究报告(2022版)
开发那些事儿:EasyCVR集群设备管理页面功能展示优化
线上开通ETF基金账户安全吗?有哪些步骤?
Cookies and session keeping technology
pyqt5中,在控件上画柱状图
How to use etcd to realize distributed /etc directory