Skip to content
Advertisement

How to filter and paginate in ListView Django

I have a problem when I want to paginate the filter that I create with django_filter, in my template it shows me the query set and filter but paginate does not work, I would like to know why this happens and if you could help me.

I’ll insert snippets of my code so you can see.

This is my views.py

PD: i have all the necesary imports.

JavaScript

filters.py

JavaScript

Advertisement

Answer

You should override get_queryset.This means you have to put your filter in get_queryset like this:

JavaScript

and use object_list instead of filter in employee_list.html like this:

JavaScript
Advertisement