当前位置:网站首页>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)
边栏推荐
- [C language supplement] judge which day tomorrow is (tomorrow's date)
- Integer array merge [JS]
- Please, stop painting star! This has nothing to do with patriotism!
- (十六)ADC转换实验
- 中国冰淇淋市场深度评估及发展趋势预测报告(2022版)
- Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
- Jojogan practice
- Unity3d extended toolbar
- Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
- FRP intranet penetration, reverse proxy
猜你喜欢
PETRv2:一个多摄像头图像3D感知的统一框架
Girls who want to do software testing look here
SystemVerilog structure (II)
剑指 Offer 20. 表示数值的字符串
Soft test network engineer full truth simulation question (including answer and analysis)
The amazing open source animation library is not only awesome, but also small
Encryption and decryption of tinyurl in leetcode
SQL注入漏洞(Mysql与MSSQL特性)
Detailed explanation of string's trim() and substring()
【splishsplash】关于如何在GUI和json上接收/显示用户参数、MVC模式和GenParam
随机推荐
开发那些事儿:EasyCVR集群设备管理页面功能展示优化
Maizeer: the two batches of products reported by the media have been taken off the shelves and sealed, and consumer appeals are accepted
美国国家安全局(NSA)“酸狐狸”漏洞攻击武器平台技术分析报告
[Supplément linguistique c] déterminer quel jour est demain (date de demain)
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
SQL注入漏洞(Mysql与MSSQL特性)
Replace UUID, nanoid is faster and safer!
Why should you consider using prism
字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
Depth first traversal and breadth first traversal [easy to understand]
ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
RadHat搭建内网YUM源服务器
在MeterSphere接口测试中如何使用JMeter函数和MockJS函数
(17) DAC conversion experiment
Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
(27) Open operation, close operation, morphological gradient, top hat, black hat
How to write good code - Defensive Programming Guide
股票万1免5证券开户是合理安全的吗,怎么讲
[wrung Ba wrung Ba is 20] [essay] why should I learn this in college?
整形数组合并【JS】