tags:

views:

141

answers:

1

I use django-paginaton app and I'm very glad to use it. Now I need feature, that I don't know how to implement. I have list of elements, that paginated by django's paginator. I have one element with specified id, that I should show, but I don't know what page contains it. I need mechanism jump to the page, that contains my element.

I think it's a good idea if django-pagination will support this transparently and automatically. For example, I set special context variable page_by_id to X and if page is None, it will be defined to the value, that contains my X element.

What do you think about this mechanism? May be there is another clean way to do this?

This is for continue of this questions:

A: 

At least, I wrote patch for django-pagination that provide 2 features:

  1. Get number of page by id of element inside paginated list;
  2. Possibility to rename default parameter 'page' to another value for using it inside template;

This works transparently by adding 2 optional parameters in autopaginate templatetag:

{% autopaginate object_list paginated_by orphans page_by_id parameter_name %}
ramusus