views:

73

answers:

1

Hi everyone. On one of my pages I would like to display a subset of a sorted list of objects. The entire list of relevant objects is extremely long and has a good chance of changing while the user is viewing the page. I don't mind that the page is not up to date, but I do need to ensure that when the user goes to the next page, the user will see the next n objects from the original sorted list. Thus, due to potentially changed data, using django's built in pagination or a really nice library like Django-endless-pagination will not return the correct results when going to the "next page".

To give an example of what I mean, say we have objects [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] and want to display 5 per page, sorted from small to big. The first page would look like:

1, 2, 3, 4, 5.

But while viewing this page, 3 and 4 were deleted. If we go to the "next" page, pagination will re-query the set and return:

8, 9, 10, 11, 12

I realize this is pagination's expected behavior, but I would like an easy way to make the next page display:

6, 7, 8, 9, 10

The most obvious solution is to do some client side pagination, and I realize there is a nice jquery library for this, but the number of objects can be potentially way too big for this solution to be realistic.

Is there a simple approach to paginate on a queryset and continue to use the results returned from that original queryset instead of re-fetching the queryset that may have changed?

Thanks for any insight you can give me!

+1  A: 

What might be a possibly solution is if you create your own pagination function that instead of the next link referring to a certain page it could pass a record that is the top record on the next page

The problem is that this would only work if the items being added/changed are only the first items in a list

Hugoagogo
+1 for a nice suggestion and pointing out its pitfall. Similarly, I could possibly store the value of the top record on the next page and grab all the results that come after that.
Spike
I'm going to mark this as accepted because you're the only one to help me out on this and your suggestion is pretty good. So, thanks!
Spike
Yea thats more or less what i meant glad to help, and thanks for the vote (means i can actually comment and vote now :) )
Hugoagogo