当前位置:网站首页>ORM -- grouping query, aggregation query, query set queryset object properties
ORM -- grouping query, aggregation query, query set queryset object properties
2022-07-07 10:07:00 【chuntian_ tester】
1. Group query
1.1. Use QuerySet object .values(‘ Parent table primary key id’).annotate( Aggregate functions (‘ From the table model, the class name is lowercase ')
1.2. The master-slave table will be automatically connected , Take the foreign key field as the grouping condition

2. Aggregate operations
2.1. Use QuerySet object .aggregate( Aggregate functions (' Field name ')) Method , Return dictionary data
2.2. In the returned dictionary data key by Field name __ Aggregate function name A lowercase letter
2.3. Key parameter form can be used , In the returned dictionary data key Is the keyword parameter name
qs = Projects.objects.filter(full_name__contains='x').aggregate(Count("id"))

qs = Projects.objects.filter(full_name__contains='x').aggregate(count=Count("id"))

3. Query set QuerySet Properties of objects :
3.1 Support chain calls
You can call... Multiple times on a query set filter(),exclude() Method
3.2 Lazy query
Execute only when using data Sql sentence , In order to improve the read and write performance of the database
3.3 Will execute Sql Statement scenario :
len(),count(), Take value through index , section ,for loop ,print etc.
边栏推荐
- 中国首款电音音频类“山野电音”数藏发售来了!
- 高斯消元
- Internship log - day04
- ES6中的原型对象
- [learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
- ES6中的函数进阶学习
- [original] what is the core of programmer team management?
- 小程序滑动、点击切换简洁UI
- Delete a record in the table in pl/sql by mistake, and the recovery method
- Sword finger offer II 107 Distance in matrix
猜你喜欢

The new activity of "the arrival of twelve constellations and goddesses" was launched

EXT2 file system

“十二星座女神降临”全新活动推出

Pit encountered by vs2015 under win7 (successful)

The Himalaya web version will pop up after each pause. It is recommended to download the client solution

request对象对请求体,请求头参数的解析

Bean 作⽤域和⽣命周期

Web3.0 series distributed storage IPFs

ORM -- query type, association query

中国首款电音音频类“山野电音”数藏发售来了!
随机推荐
Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
Scratch crawler mysql, Django, etc
14th test
Addition, deletion, modification and query of ThinkPHP database
位操作==c语言2
Enterprise practice | construction of banking operation and maintenance index system under complex business relations
[learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
能源路由器入门必读:面向能源互联网的架构和功能
C socke server, client, UDP
Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat
大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消
A wave of open source notebooks is coming
Garbage disposal method based on the separation of smart city and storage and living digital home mode
ORM--数据库增删改查操作逻辑
Some test points about coupon test
Postman interface test I
Writing file types generated by C language
HCIP 第一天 笔记整理
小程序弹出半角遮罩层