当前位置:网站首页>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.
边栏推荐
- Phpcms realizes PC website access to wechat native payment
- Pit using BigDecimal
- Addition, deletion, modification and query of ThinkPHP database
- 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
- EXT2 file system
- ORM模型--关联字段,抽象模型类
- 高数_第1章空间解析几何与向量代数_向量的数量积
- Guys, have you ever encountered the case of losing data when Flink CDC reads mysqlbinlog? Every time the task restarts, there is a probability of losing data
- Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
- Google colab loads Google drive (Google drive is used in Google colab)
猜你喜欢
Qualifying 3
Deconvolution popular detailed analysis and nn Convtranspose2d important parameter interpretation
Arcgis操作: 批量修改属性表
中国首款电音音频类“山野电音”数藏发售来了!
ORM模型--数据记录的创建操作,查询操作
Switching value signal anti shake FB of PLC signal processing series
喜马拉雅网页版每次暂停后弹窗推荐下载客户端解决办法
Agile course training
Win10安装VS2015
[original] what is the core of programmer team management?
随机推荐
Bean 作⽤域和⽣命周期
哈夫曼编码压缩文件
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
Check the example of where the initialization is when C initializes the program
ORM--逻辑关系与&或;排序操作,更新记录操作,删除记录操作
Postman tutorial - scripting
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
Or in SQL, what scenarios will lead to full table scanning
Selenium+bs4 parsing +mysql capturing BiliBili Tarot data
The applet realizes multi-level page switching back and forth, and supports sliding and clicking operations
Analyze Android event distribution mechanism according to popular interview questions (I)
字节跳动 Kitex 在森马电商场景的落地实践
Use 3 in data modeling σ Eliminate outliers for data cleaning
In addition to the objective reasons for overtime, what else is worth thinking about?
There is a problem using Chinese characters in SQL. Who has encountered it? Such as value & lt; & gt;` None`
Codeforces - 1324d pair of topics
Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat
Pit using BigDecimal
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
Guys, have you ever encountered the case of losing data when Flink CDC reads mysqlbinlog? Every time the task restarts, there is a probability of losing data