Django数据统计功能count()的使用
作者:汤圆儿2019 时间:2022-12-21 23:49:29
一、view实现计数
在apiviews.py中加入以下内容
from ApiTest.models import ApiTest
from django.shortcuts import render
def api_test_manage(request):
apitest_count = ApiTest.objects.all().count()
return render(request, "apitest_manage.html", {'user': username, 'apitests': apitest_list, 'apitests_count': apitest_count})
二、Html将数据渲染展示
在apitest_manage.html中加入:
<!-- 将翻页功能固定在右下角>
<span style="position:absolute; right:100px; bottom: 30px;">
<div style="position:absolute; right:100px; bottom: 15px;">
<tr><th>总数: </th><td>{{ apitests_count }}</td></tr>
</div>
三、效果展示
来源:https://blog.csdn.net/weixin_38851970/article/details/107556963
标签:Django,count()
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
mysql启用skip-name-resolve模式时出现Warning的处理办法
2024-01-20 06:44:58
解决Python字典查找报Keyerror的问题
2021-05-07 00:53:55
![](https://img.aspxhome.com/file/2023/0/100800_0s.png)
Django接受前端数据的几种方法总结
2021-11-26 23:32:53
如何在ASP里面创建GUID
2008-01-08 19:13:00
Python实现批量检测HTTP服务的状态
2023-02-21 12:50:55
![](https://img.aspxhome.com/file/2023/6/131406_0s.png)
nodejs高版本降为低版本的详细解决方案
2024-05-02 17:40:25
![](https://img.aspxhome.com/file/2023/3/129473_0s.png)
Refactoring HTML 书评
2008-07-10 12:00:00
Mysql8.0递归查询的简单用法示例
2024-01-22 16:06:42
用python画圣诞树三种代码示例介绍
2023-03-24 08:15:01
![](https://img.aspxhome.com/file/2023/6/97356_0s.jpg)
Android ProgressBar进度条和ProgressDialog进度框的展示DEMO
2023-11-20 01:15:43
![](https://img.aspxhome.com/file/2023/1/95001_0s.jpg)
通过百度地图获取公交线路的站点坐标的js代码
2024-04-18 09:28:14
Python下载网易云歌单歌曲的示例代码
2023-06-10 17:06:28
![](https://img.aspxhome.com/file/2023/9/103019_0s.png)
Python ORM框架Peewee用法详解
2022-11-08 03:00:24
![](https://img.aspxhome.com/file/2023/1/101101_0s.png)
python中pathlib模块的基本用法与总结
2023-12-11 15:54:17
![](https://img.aspxhome.com/file/2023/3/105453_0s.png)
Python使用爬虫爬取贵阳房价的方法详解
2022-12-01 09:55:25
![](https://img.aspxhome.com/file/2023/4/87934_0s.jpg)
判断sql语句执行是否成功
2008-07-05 12:22:00
python hmac模块验证客户端的合法性
2021-08-21 19:18:11
浅谈JavaScript窗体Window.ShowModalDialog使用
2024-04-23 09:05:39
Python中Parser的超详细用法实例
2022-05-02 10:16:30
Python如何合并多个字典或映射
2023-11-07 17:20:51