how can I use pagination with django_filter

后端 未结 3 1448
孤独总比滥情好
孤独总比滥情好 2021-01-15 05:09

I got a problem with pagination after using django_filter in my TemplateView. Before use django_filter, my pagination was working normally but now it show all the items in e

3条回答
  •  执念已碎
    2021-01-15 05:52

    Personally I use django-tables with django-filter and that takes care of the pagination for me, so I'm no expert on this. However it seems that you need to paginate the results of the filter once you have them in your view. Perhaps something like this?

    paginator = Paginator(data, 10)
    

    Check out this posting on SO. Django Filter with Pagination and also this website explains how to do it generically. https://djangopy.org/how-to/pagination-with-django/

提交回复
热议问题