当前位置:网站首页>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)
边栏推荐
- 整形数组合并【JS】
- mysql -- explain性能优化
- Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
- Sword finger offer 20 String representing numeric value
- Jojogan practice
- 在MeterSphere接口测试中如何使用JMeter函数和MockJS函数
- Is it safe to open a stock account by mobile phone? What do you need to bring with you to open an account?
- Depth first traversal and breadth first traversal [easy to understand]
- 剑指 Offer 20. 表示数值的字符串
- 换掉UUID,NanoID更快更安全!
猜你喜欢

Redis6.0 new features

How wild are hackers' ways of making money? CTF reverse entry Guide

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

整形数组合并【JS】

ACL 2022 | decomposed meta learning small sample named entity recognition

Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!

Soft test network engineer full truth simulation question (including answer and analysis)

(十七)DAC转换实验

Oom caused by improper use of multithreading

可迭代对象与迭代器、生成器的区别与联系
随机推荐
开发那些事儿:EasyCVR集群设备管理页面功能展示优化
June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries
走进微信小程序
Research Report on development monitoring and investment prospects of China's smart environmental protection industry (2022 Edition)
Research Report on China's enzyme Market Forecast and investment strategy (2022 Edition)
C language implementation of sum of two numbers [easy to understand]
Maizeer: the two batches of products reported by the media have been taken off the shelves and sealed, and consumer appeals are accepted
中国酶制剂市场预测与投资战略研究报告(2022版)
String class
Vulnhub range hacker_ Kid-v1.0.1
Basic usage of Frida
How to use etcd to realize distributed /etc directory
期货先锋这个软件正规吗安全吗?选择哪家期货公司更安全?
Roewe rx5's "a little more" product strategy
Is it safe to open a stock account by mobile phone? What do you need to bring with you to open an account?
GameFramework食用指南
6月刊 | AntDB数据库参与编写《数据库发展研究报告》 亮相信创产业榜单
Detailed explanation of string's trim() and substring()
(十六)ADC转换实验
Judge whether the binary tree is a binary search tree