1.源碼方式安裝xadmin
安裝說明:https://blog.csdn.net/baoshuowl/article/details/80355807
報(bào)錯(cuò)解決:http://www.lybbn.cn/data/bbsdatas.php?lybbs=50
2.開發(fā)需求
增加前端分頁
效果如下:
3.開發(fā)思路
? ? 1.理清xadmin 后臺執(zhí)行邏輯(可以使用debug django來觀看項(xiàng)目執(zhí)行過程 參考:https://www.cnblogs.com/Rocky_/p/6187275.html)
? ? ? ? 參考:https://xadmin.readthedocs.io/en/docs-chinese/index.html
? ? 2.定位前端文件?extra_apps/xadmin/templates/xadmin/views/model_list.html??
<div class="content-toolbar btn-toolbar pull-right clearfix"> 下插入
{# 分頁條數(shù) #}
<div class="btn-group">
????<a class="dropdown-toggle btn btn-default btn-sm" data-toggle="dropdown" href="#">分頁條數(shù) <span class="caret"></span> </a>
<ul class="dropdown-menu model_fields pull-right" role="menu" aria-labelledby="dLabel">
????<li><a href="?list_per_page=3">3</a></li>
? ? <li><a href="?list_per_page=5">5</a></li> <li><a href="?list_per_page=10">10</a>? ? ? ? </li>
????<li><a href="?list_per_page=20">20</a></li>
</ul>
</div>
{# 分頁條數(shù) #}
? ??extra_apps/xadmin/views/list.py
@filter_hook
def get_paginator(self):
????list_per_page = self.request.GET.get("list_per_page")
????if list_per_page:
????????self.list_per_page = int(list_per_page)
return self.paginator_class(self.list_queryset, self.list_per_page, 0, True)
開發(fā)前頁面:
開發(fā)后: