当前位置:网站首页>Relevant knowledge of DRF
Relevant knowledge of DRF
2022-06-26 08:13:00 【As long as you don't lose your mind, there are more ways than d】
1.default_permissions = (), Clear the four default permissions , Namely add model, change model and delete model.
2.
on_delete = None:
When deleting the data of the associated table , Current table and associated table filed act .
on_delete = models.CASCADE:
Indicates cascade delete , When associated table ( Sub table ) When deleting data in , The corresponding foreign key ( Parent table ) Also delete the data in .
on_delete = models.DO_NOTHING:
You delete your , father ( Foreign keys ) I don't want to care about you
on_delete = models.PROTECT:
Protected mode , If this method is adopted , When the associated data is deleted, an ProtectError error
(5)、on_delete = models.SET_DEFAULT:
Set the default value , When deleting sub table fields , The foreign key field is set to the default value , So when defining a foreign key, you should add a default value .
(6)、on_delete = models.SET( value ):
When deleting associated data , Customize a value , The value can only correspond to the specified entity
3.order_by Usage of
Test.objects.all().order_by('id') Ascending From small to large
Test.objects.all().order_by('-id') Descending From big to small
边栏推荐
- Solve the problem that pychar's terminal cannot enter the venv environment
- ReW_p
- buuresevewp
- Bluebridge cup 1 introduction training Fibonacci series
- 45. jumping game II dynamic planning DP
- Pic 10B parsing
- Install the local Google plug-in and watch the free video through the oil monkey script
- 1002: easy to remember phone number
- What if the service in Nacos cannot be deleted?
- Rewrite string() method in go language
猜你喜欢

What if the service in Nacos cannot be deleted?

MySQL practice: 1 Common database commands

How to design API return codes (error codes)?

Hand drawn style chart library chart Implementation principle of xkcd

MySQL insert Chinese error

PyTorch-12 GAN、WGAN

See which processes occupy specific ports and shut down
![[industry cloud talk live room] tomorrow afternoon! Focus on digital intelligence transformation of the park](/img/20/05f0a2dfb179a89188fbb12605370c.jpg)
[industry cloud talk live room] tomorrow afternoon! Focus on digital intelligence transformation of the park
![[postgraduate entrance examination] group planning exercises: memory](/img/ac/5c63568399f68910a888ac91e0400c.png)
[postgraduate entrance examination] group planning exercises: memory

How to debug plug-ins using vs Code
随机推荐
Household enterprises use WMS warehouse management system. What are the changes
Ora-12514: tns: the listener currently does not recognize the service requested in the connection descriptor
Uniapp uses uviewui
I want to create SQL data (storage structure)
Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI
Double linked list -- tail interpolation construction (C language)
MySQL query time period
What is the five levels of cultivation of MES management system
Informatics Orsay all in one 1354: bracket matching test
h5 localStorage
MFC writes a suggested text editor
Chapter VII (structure)
PyTorch-12 GAN、WGAN
Late 2021 plan
MySQL practice: 4 Operation of data
ECE 9203/9023 analysis
Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax
PyTorch-12 GAN、WGAN
Handwritten instanceof underlying principle
"System error 5 occurred when win10 started mysql. Access denied"