当前位置:网站首页>ORM -- logical relation and & or; Sort operation, update record operation, delete record operation
ORM -- logical relation and & or; Sort operation, update record operation, delete record operation
2022-07-07 10:07:00 【chuntian_ tester】
1. logical relationship
1.1 And
1.1.1 filter() Separate multiple filter conditions with commas in
qs = Projects.objects.filter(id='xx', full_name='xxx')
1.1.2 Chain multiple calls filter() Method
qs = Projects.objects.filter(full_name='xxx').filter('id'='xx')
1.2 or
Use Q Class to specify or relate , For filtering conditions | Separate
qs = Projects.objects.filter(Q(full_name__contains='2') | Q(leader='jeanet'))
2. The sorting operation
QuerySet object .order_by("-id",'full_name')
Use QuerySet object .order_by(‘ Field 1’,‘ Field 2’,‘- Field 3’), By default asc Sort , You can add ‘-’ To specify the desc Descending
3. Update record operation
3.1 adopt obj. Field name =xxxx Pass after covering obj.save() Method preservation , It is for the record to be fully updated
adopt obj. Field name =xxxx Pass after covering obj.save(update_fields=[“ Field 1“,” Field 2“]) Method preservation ,
Specify the updated fields , Is to update some fields
3.2 adopt QuerySet object .update( Field name =‘xxx‘) Update multiple data
4. Delete record
4.1 QuerySet object .delete(), Delete multiple records
4.2 obj.delete(), Delete a single record
边栏推荐
- [untitled]
- ORM--数据库增删改查操作逻辑
- Google Colab装载Google Drive(Google Colab中使用Google Drive)
- Codeforces - 1324d pair of topics
- EXT2 file system
- 小程序弹出半角遮罩层
- CSDN salary increase technology - learn about the use of several common logic controllers of JMeter
- There is a problem using Chinese characters in SQL. Who has encountered it? Such as value & lt; & gt;` None`
- 小程序实现页面多级来回切换支持滑动和点击操作
- AI从感知走向智能认知
猜你喜欢
Introduction to energy Router: Architecture and functions for energy Internet
Win10 installation vs2015
Web3.0 series distributed storage IPFs
arcgis操作:dwg数据转为shp数据
VS Code指定扩展安装位置
小程序实现页面多级来回切换支持滑动和点击操作
内存==c语言1
【无标题】
【ORM框架】
The applet realizes multi-level page switching back and forth, and supports sliding and clicking operations
随机推荐
Bean 作⽤域和⽣命周期
Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
Postman interface test I
A wave of open source notebooks is coming
Do you have a boss to help look at this error report and what troubleshooting ideas are there? Oracle CDC 2.2.1 flick 1.14.4
Use 3 in data modeling σ Eliminate outliers for data cleaning
C socke server, client, UDP
Apprentissage avancé des fonctions en es6
Deadlock caused by non clustered index in SQL Server
flinkcdc采集oracle在snapshot阶段一直失败,这个得怎么调整啊?
Write it into the SR table in the way of flinksql. It is found that the data to be deleted has not been deleted. Refer to the document https://do
【原创】程序员团队管理的核心是什么?
Guys, how can mysql-cdc convert the upsert message to append only
request对象对请求体,请求头参数的解析
为什么安装mysql时starting service报错?(操作系统-windows)
Hcip first day notes sorting
Bit operation ==c language 2
Finally, there is no need to change a line of code! Shardingsphere native driver comes out
大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消
Huffman encoded compressed file