Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulating queryset chunks in the view #110

Open
burakozdemir32 opened this issue Mar 15, 2018 · 1 comment
Open

Manipulating queryset chunks in the view #110

burakozdemir32 opened this issue Mar 15, 2018 · 1 comment

Comments

@burakozdemir32
Copy link

On the template side it works nice and retrieves 10 items for every scroll down. However, the problem is that the query initialization time is too long. In the '_format_items()' function, all the items are iterated, not only chunks. I tried sending a part of the queryset to '_format_items()' function(queryset[x:y]) but then after the first page load on the template it didn't retrieve rest of the items on scroll down.

queryset = Items.objects.filter(
    user_id=1
)
formatted_items = self._format_items(queryset)
data = {'items': formatted_items}
if request.is_ajax():
    self.template_name = 'templates/items_list.html'

return render(request, self.template_name, data)
@shtalinberg
Copy link
Owner

I think problem in you _format_items function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants