0

I am using django-el-pagination in Django project to show documents.

But I found that when I have more than 90k documents, the page loads very slowly.

I think that 'get_queryset' function runs again when sending ajax to load more.

This makes page load slowly.

Is there any way to slice the existing objects list instead of query all objects again.

class IndexView(AjaxListView):
    template_name = 'entry/index.html'
    context_object_name = 'entity_list'
    page_template = 'entry/entry_list_page.html'

    def get_queryset(self):
        <--My code to get objects-->
        return <objects>
Taosky
  • 11
  • 5

1 Answers1

0

Found the problem, my old code query all objects every time,

return Entry.objects.filter().order_by('date')[::-1]

and the new code will run internal query command to query severl objects each time.

return Entry.objects.filter().order_by('date')

With elasticsearch, I use the answer here, it create a proxy between the Paginator and the Elasticsearch query.

Taosky
  • 11
  • 5