Django數(shù)據(jù)統(tǒng)計(jì)功能count()的使用
一、view實(shí)現(xiàn)計(jì)數(shù)
在apiviews.py中加入以下內(nèi)容
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將數(shù)據(jù)渲染展示
在apitest_manage.html中加入:
<!-- 將翻頁(yè)功能固定在右下角><span style='position:absolute; right:100px; bottom: 30px;'><div style='position:absolute; right:100px; bottom: 15px;'> <tr><th>總數(shù): </th><td>{{ apitests_count }}</td></tr></div>
三、效果展示
到此這篇關(guān)于Django數(shù)據(jù)統(tǒng)計(jì)功能count()的使用的文章就介紹到這了,更多相關(guān)Django count()內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 完美解決vue 中多個(gè)echarts圖表自適應(yīng)的問(wèn)題2. SpringBoot+TestNG單元測(cè)試的實(shí)現(xiàn)3. vue實(shí)現(xiàn)web在線聊天功能4. idea配置jdk的操作方法5. Docker容器如何更新打包并上傳到阿里云6. Springboot 全局日期格式化處理的實(shí)現(xiàn)7. python 浮點(diǎn)數(shù)四舍五入需要注意的地方8. IntelliJ IDEA設(shè)置默認(rèn)瀏覽器的方法9. Java GZip 基于內(nèi)存實(shí)現(xiàn)壓縮和解壓的方法10. JAMon(Java Application Monitor)備忘記
