0

I am new to python and I am using django class based pagination with below code:

class Demo(LoginRequiredMixin, ListView):
    model = users
    template_name = 'users_list.html'
    context_object_name = 'users'
    filterset_class = users
    paginate_by = 10

    def get_queryset(self):

        // Code goes here
        // Result array after custom array creation from querySet result : {25474: {'address__is_active': 1, 'id': 1, 'updated_by': '', 'count': 1}, 25475: {'address__is_active': 1, 'id': 2, 'count': 1, 'updated_by': ''}}

        return qs

    def get_context_data(self, **kwargs):
        context = super(Demo, self).get_context_data(**kwargs)
        context['filter_form'] = UserFilterForm(self.request.GET)
        page_query = ''
        for key,value in self.request.GET.items():
            if key != 'page':
                page_query+='&'+key+'='+value
        context['page_query'] = page_query
        return context

I am able to see pagination UI in my list but pagination is not working properly. I am getting all records in one page. I have queryset like below:

[{'dCount1': 1, 'address__updated_by': '', 'address__id': 25474, 'status': 2, 'dCount': 1, 'user_id': 1}, {'dCount1': 1, 'address__updated_by': '', 'address__id': 25475, 'status': 3, 'dCount': 1, 'user_id': 2}]

Could anyone please assist how I can use class based pagination on above queryset.

Nilesh Kumar
  • 370
  • 2
  • 3
  • 16

0 Answers0