django - 分页不适用于过滤 Django
问题描述
我有一个Listview
与分页完美配合的,它看起来像:
class BranchListView(ListView):
model = Branch
paginate_by = 10
现在我需要将其更改为Filterview
并使用django_filters
,我正在尝试以FilterView
这种方式创建分页
class BranchListView(FilterView):
model = Branch
paginate_by = 10
filter_class = BranchFilter
template_name = 'erp_system/branch_list.html'
filterset_fields = ['id', 'name']
这就是我在模板中使用分页部分的方式
{% if is_paginated %}
<div class="pagination">
<span class="page-links">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}"><button
class="btn-success">الصفحة السابقة</button> </a>
{% endif %}
<span class="page-current">
صفحة رقم {{ page_obj.number }} من {{ page_obj.paginator.num_pages }}.
</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}"><button class="btn-success">الصفحة التالية</button> </a>
{% endif %}
</span>
</div>
{% endif %}
现在过滤工作正常。但是根本没有分页。
解决方案
推荐阅读
- opcode - 芯片 8 操作码 FX65 中的增量 I
- .net - vb net 单击网页上的选项卡按钮
- javascript - JavaScript 中的 getYear() 返回 118
- javascript - Javascript 录音到 MongoDB
- php - ajax 到 php $ 变量
- intellij-idea - 在 IntelliJ 的 AB 的包 A 中创建类
- html - CSS将img水平和垂直居中而不调整大小
- r - R - 为什么我的曲线不是从 (0,1) 开始?
- json - 试图再次打羊
- android - 是否可以在 AndroidStudio 中使用 nidi.guru Graphviz 实现?