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中加入:
<!-- 將翻頁功能固定在右下角><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. Spring security 自定義過濾器實(shí)現(xiàn)Json參數(shù)傳遞并兼容表單參數(shù)(實(shí)例代碼)2. Java8內(nèi)存模型PermGen Metaspace實(shí)例解析3. python tkinter實(shí)現(xiàn)下載進(jìn)度條及抖音視頻去水印原理4. 一文搞懂 parseInt()函數(shù)異常行為5. 聊聊python在linux下與windows下導(dǎo)入模塊的區(qū)別說明6. python學(xué)習(xí)之plot函數(shù)的使用教程7. python 實(shí)現(xiàn)"神經(jīng)衰弱"翻牌游戲8. ASP.NET MVC使用正則表達(dá)式驗(yàn)證手機(jī)號(hào)碼9. Python基于百度AI實(shí)現(xiàn)抓取表情包10. python中用Scrapy實(shí)現(xiàn)定時(shí)爬蟲的實(shí)例講解
