您的位置:首頁技術文章
文章詳情頁

Django數據統計功能count()的使用

瀏覽:101日期:2024-09-16 08:06:54

一、view實現計數

在apiviews.py中加入以下內容

from ApiTest.models import ApiTestfrom django.shortcuts import renderdef 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()的使用

到此這篇關于Django數據統計功能count()的使用的文章就介紹到這了,更多相關Django count()內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Django
相關文章:
国产综合久久一区二区三区