Django数据统计功能count()的使用

一、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>

三、效果展示

Django数据统计功能count()的使用

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容