当前位置:网站首页>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') 降序 从大到小
边栏推荐
- Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax
- Win10 mysql-8.0.23-winx64 solution for forgetting MySQL password (detailed steps)
- Hand drawn style chart library chart Implementation principle of xkcd
- Oracle 19C local listener configuration error - no listener
- [postgraduate entrance examination planning group] conversion between signed and unsigned numbers
- 1. error using XPath to locate tag
- StarWar armor combined with scanning target location
- Use of jupyter notebook
- Flume learning notes
- h5 localStorage
猜你喜欢

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

Chapter VIII (classes and objects)

Real machine debugging of uniapp custom base

Getdrawingcache of view is empty. Solution: interview questions for Android audio and video development

Detailed explanation and code implementation of soft voting and hard voting mechanism in integrated learning

Rewrite string() method in go language

Baoyan postgraduate entrance examination interview - operating system

1. error using XPath to locate tag

Detailed explanation of the generate go file command of import in golang (absolute detail)

Double linked list -- tail interpolation construction (C language)
随机推荐
Oracle 19C download installation steps
JMeter performance testing - Basic Concepts
Project management learning
Ping An technology's practice of migrating from Oracle to ubisql
2022 ranking of bank financial products
Go语言浅拷贝与深拷贝
项目管理学习
See which processes occupy specific ports and shut down
[postgraduate entrance examination planning group] conversion between signed and unsigned numbers
Gavin teacher's insight on transformer live class - multi state transition of financial BOT and rasa interactive behavior analysis of Rasa project (52)
Basic use of swiperefreshlayout, local refresh of flutterprovider
Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI
Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax
Use intent to shuttle between activities -- use explicit intent
4 best practices for wireless (OTA) updates
Handwritten instanceof underlying principle
Getdrawingcache of view is empty. Solution: interview questions for Android audio and video development
What are the key points of turnover box management in warehouse management
1002: easy to remember phone number
Oracle database self study notes