当前位置:网站首页>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
边栏推荐
猜你喜欢

ASP. Net and Net framework and C #

Wifi-802.11 2.4G band 5g band channel frequency allocation table

Hand drawn style chart library chart Implementation principle of xkcd

1. error using XPath to locate tag

Go语言浅拷贝与深拷贝

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

How to define a digital factory and what is the relationship with smart factory and industry 4.0

Getting started with idea

MySQL practice: 1 Common database commands

Go language shallow copy and deep copy
随机推荐
[untitled]
MySQL practice: 2 Table definition and SQL classification
Use intent to shuttle between activities -- use implicit intent
arduino——ATtiny85 SSD1306 + DHT
Pychart connects to Damon database
JWT in go
Area of Blue Bridge Cup 2 circle
WiFi-802.11 2.4G频段 5G频段 信道频率分配表
How to design API return codes (error codes)?
Seven important reasons for responsive Web Design
Rewrite string() method in go language
Opencv mouse event + interface interaction drawing rectangle polygon selection ROI
Livevideostackcon | evolution of streaming media distribution for online education business
Basic use of swiperefreshlayout, local refresh of flutterprovider
What are the key points of turnover box management in warehouse management
How to define a digital factory and what is the relationship with smart factory and industry 4.0
JMeter performance testing - Basic Concepts
Win10 mysql-8.0.23-winx64 solution for forgetting MySQL password (detailed steps)
Uni app is similar to Taobao in selecting multiple specifications of commodities (inventory judgment)
Chapter VIII (classes and objects)