当前位置:网站首页>drf的相关知识
drf的相关知识
2022-06-26 08:12:00 【只要思想不滑坡办法总比困难多--小鱼干】
1.default_permissions = (),清空默认的四个权限,分别是add model, change model和delete model。
2.
on_delete = None:
删除关联表的数据时,当前表与关联表的filed的行为。
on_delete = models.CASCADE:
表示级联删除,当关联表(子表)中的数据删除时,与其相对应的外键(父表)中的数据也删除。
on_delete = models.DO_NOTHING:
你删你的,父亲(外键)不想管你
on_delete = models.PROTECT:
保护模式,如采用这个方法,在删除关联数据时会抛出ProtectError错误
(5)、on_delete = models.SET_DEFAULT:
设置默认值,删除子表字段时,外键字段设置为默认值,所以定义外键的时候注意加上一个默认值。
(6)、on_delete = models.SET(值):
删除关联数据时,自定义一个值,该值只能是对应指定的实体
3.order_by的用法
Test.objects.all().order_by('id') 升序 从小到大
Test.objects.all().order_by('-id') 降序 从大到小
边栏推荐
- MySQL query time period
- Multi interface switching in one UI of QT
- ReW_ p
- Blue Bridge Cup 3 sequence summation
- 2022 ranking of bank financial products
- Wifi-802.11 2.4G band 5g band channel frequency allocation table
- How to debug plug-ins using vs Code
- "System error 5 occurred when win10 started mysql. Access denied"
- Mapping '/var/mobile/Library/Caches/com.apple.keyboards/images/tmp.gcyBAl37' failed: 'Invalid argume
- [industry cloud talk live room] tomorrow afternoon! Focus on digital intelligence transformation of the park
猜你喜欢

解决 psycopg2.NotSupportedError: PQconninfo not available in libpq < 9.3

MySQL insert Chinese error

WiFi-802.11 2.4G频段 5G频段 信道频率分配表

I want to create SQL data (storage structure)

Wechat applet beginner level chapter

Google Earth engine (GEE) 02 basic knowledge and learning resources

Opencv mouse event + interface interaction drawing rectangle polygon selection ROI

Rewrite string() method in go language

(vs2019 MFC connects to MySQL) make a simple login interface (detailed)

MySQL practice: 3 Table operation
随机推荐
[issue 22] sheen cloud platform one side & two sides
Delete dictionary from list
Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI
Real machine debugging of uniapp custom base
[postgraduate entrance examination] group planning: interrupted
PCB miscellaneous mail
Okhttp3 source code explanation (IV) cache strategy, disadvantages of Android mixed development
ASP. Net and Net framework and C #
Livevideostackcon | evolution of streaming media distribution for online education business
Gavin teacher's insight on transformer live class - multi state transition of financial BOT and rasa interactive behavior analysis of Rasa project (52)
MySQL practice: 4 Operation of data
Getdrawingcache of view is empty. Solution: interview questions for Android audio and video development
loading view时,后面所有东西屏蔽
记一次开发 pgadmin 时执行 Building the Web Assets 遇到的依赖安装问题
Google Earth Engine(GEE) 01-中输入提示快捷键Ctrl+space无法使用的问题
我想造SQL数据(存储结构)
Uni app is similar to Taobao in selecting multiple specifications of commodities (inventory judgment)
Solve psycopg2 NotSupportedError: PQconninfo not available in libpq < 9.3
Uni app installation and project directory (hbuilder configuration)
The solution of installing opencv with setting in pycharm