当前位置:网站首页>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.
边栏推荐
- Introduction to automated testing framework
- ES类和对象、原型
- HCIP 第一天 笔记整理
- ISP、IAP、ICP、JTAG、SWD的编程特点
- ORM model -- associated fields, abstract model classes
- Sqlplus garbled code problem, find the solution
- Postman interface test I
- Deadlock caused by non clustered index in SQL Server
- Applet sliding, clicking and switching simple UI
- Win10安装VS2015
猜你喜欢

小程序弹出半角遮罩层

Google colab loads Google drive (Google drive is used in Google colab)

Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is

Pit using BigDecimal

Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat

Flex flexible layout

XML配置文件解析与建模

Arcgis操作: 批量修改属性表

arcgis操作:dwg数据转为shp数据

Detailed explanation of diffusion model
随机推荐
哈夫曼编码压缩文件
官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展
Why are social portals rarely provided in real estate o2o applications?
CSDN salary increase technology - learn about the use of several common logic controllers of JMeter
第十四次试验
ORM模型--关联字段,抽象模型类
Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
Using keras in tensorflow to build convolutional neural network
ES6中的函数进阶学习
Bit operation ==c language 2
CDZSC_2022寒假个人训练赛21级(2)
phpcms实现PC网站接入微信Native支付
中国首款电音音频类“山野电音”数藏发售来了!
14th test
ORM--分组查询,聚合查询,查询集QuerySet对象特性
The combination of over clause and aggregate function in SQL Server
Arcgis操作: 批量修改属性表
ORM--数据库增删改查操作逻辑
ORM--逻辑关系与&或;排序操作,更新记录操作,删除记录操作
Please ask me a question. I started a synchronization task with SQL client. From Mysql to ADB, the historical data has been synchronized normally