当前位置:网站首页>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.
边栏推荐
- 2016 CCPC Hangzhou Onsite
- Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is
- Sqlplus garbled code problem, find the solution
- 高斯消元
- ORM -- query type, association query
- Postman interface test I
- [Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
- Luogu p2482 [sdoi2010] zhuguosha
- Memory ==c language 1
- Horizontal split of database
猜你喜欢
Qualifying 3
[untitled]
request对象对请求体,请求头参数的解析
ISP、IAP、ICP、JTAG、SWD的编程特点
“十二星座女神降临”全新活动推出
Natapp intranet penetration
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
Memory ==c language 1
字节跳动 Kitex 在森马电商场景的落地实践
随机推荐
Software modeling and analysis
ORM模型--数据记录的创建操作,查询操作
The new activity of "the arrival of twelve constellations and goddesses" was launched
有没有大佬帮忙看看这个报错,有啥排查思路,oracle cdc 2.2.1 flink 1.14.4
ES6中的函数进阶学习
Can't connect to MySQL server on '(10060) solution summary
2020浙江省赛
CDZSC_2022寒假个人训练赛21级(1)
Huffman encoded compressed file
Gym - 102219J Kitchen Plates(暴力或拓扑序列)
Internship log - day07
中国首款电音音频类“山野电音”数藏发售来了!
ES6中的函數進階學習
arcgis操作:dwg数据转为shp数据
Memory ==c language 1
第十四次试验
[untitled]
为什么安装mysql时starting service报错?(操作系统-windows)
2016 CCPC Hangzhou Onsite
XML配置文件解析与建模