I am making an app that lists a number of objects using the tried and true paginator to which you pass a fairly arbitrary queryset.
The issue is I want users to be able to save a link to a specific entry without having them specify which page in a multipage listing to go to. It is probably easier to show with some url examples. So, let us say we are on some page of a listing of posts in a discussion. Each post on this listing has a 'permalink' that users can copy and use later. This permalink looks something like this: /assforums/discs/2/?post=22 This means 'find the page of the listing of posts for discussion pk=2 that post pk=22 is on' In my example let us this say this on page 2. I am looking for an efficient way to take the query set of "all the posts in discussion pk = 2" and get the page number that "post pk = 22" is on. I can then pass this as the "page" parameter in to the paginator and the view will be rendered with that. Now I can obviously just start slicing the query set by the page size looking for the page where this post occurs but that causes me to actually start resolving the query set. This would not be very efficient if we had a lot of 'posts' in that query set. Of course one should not assume that post pk's are monotonically increasing as the order the query set is sorted by can have no relation to the post pk's. This means we can not even do something simple as a binary search of slices of the query set. If I could find an efficient way to do "find the index in the given qs of the object with pk = <foo>" I could then do some simple math to calculate which page the object would appear on the final listing. The key being I would like this to be as efficient as possible. Hopefully I explained that in a non-confusing way? Any help would be appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---