当前位置:网站首页>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
边栏推荐
- 2016 CCPC Hangzhou Onsite
- CDZSC_ 2022 winter vacation personal training match level 21 (1)
- Pytest learning - dayone
- Application of C # XML
- AI从感知走向智能认知
- XML配置文件解析与建模
- MySQL can connect locally through localhost or 127, but cannot connect through intranet IP (for example, Navicat connection reports an error of 1045 access denied for use...)
- Garbage disposal method based on the separation of smart city and storage and living digital home mode
- Arcgis操作: 批量修改属性表
- Gauss elimination
猜你喜欢
【原创】程序员团队管理的核心是什么?
基础篇:带你从头到尾玩转注解
官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展
企业实战|复杂业务关系下的银行业运维指标体系建设
农牧业未来发展蓝图--垂直农业+人造肉
Qualifying 3
Bean 作⽤域和⽣命周期
Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat
AI moves from perception to intelligent cognition
ORM--分组查询,聚合查询,查询集QuerySet对象特性
随机推荐
Interface test
Analyze Android event distribution mechanism according to popular interview questions (II) -- event conflict analysis and handling
How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
Delete a record in the table in pl/sql by mistake, and the recovery method
基础篇:带你从头到尾玩转注解
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
小程序实现页面多级来回切换支持滑动和点击操作
ORM模型--关联字段,抽象模型类
Natapp intranet penetration
大佬们,有没有遇到过flink cdc读MySQLbinlog丢数据的情况,每次任务重启就有概率丢数
Enterprise practice | construction of banking operation and maintenance index system under complex business relations
web3.0系列之分布式存储IPFS
The applet realizes multi-level page switching back and forth, and supports sliding and clicking operations
In addition to the objective reasons for overtime, what else is worth thinking about?
网上可以开炒股账户吗安全吗
Can't connect to MySQL server on '(10060) solution summary
Can flycdc use SqlClient to specify mysqlbinlog ID to execute tasks
Huffman encoded compressed file
高数_第1章空间解析几何与向量代数_向量的数量积
2016 CCPC Hangzhou Onsite