﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2574	[patch] object_list passes in list of page numbers, the first and last object numbers and accepts lists as well as querysets	grimboy	Adrian Holovaty	"This patch adds three improvements.

The first improvement this patch adds is that the object_list view passes in a list of page numbers called page_list to the template. By default this list contains all the valid pages. The arguements page_list_surround and page_list_edges are two integers that can be passed in to override the default (in case your results have too many pages). page_list_surround defines how many pages on each side of the current page should be included in page_list, so if the current page is 5 and there are 10 pages a page_list_surround of 3 would pass the template a list like [""sep"", 2, 3, 4, 5, 6, 7, 8, ""sep""]. page_list_edges allows you to include the first and last few pages as well, so if the current page is 10, there are 20 pages and page_list_surround is 3 a page_list_edges of 3 would pass the template a list like [1, 2, 3, ""sep"", 7, 8, 9, 10, 11, 12, 13, ""sep"", 18, 19, 20]. The sep strings are there to show that more pages exist. This should be overridden using simple template logic such as {% ifequal other_page ""sep"" %}...{% endifqual %} or it can be ignored by putting everything within the loop of page_list in a {% ifnotequal other_page ""sep"" %} tag.

That may have been slightly badly explained so here is a template example:

{{{
{% if is_paginated %}
    <div class=""Paginator"">
        {% for other_page in page_list %}
            {% ifequal other_page page %}
                <span class=""this-page"">{{ page }}</span>
            {% else %}{% ifequal other_page ""sep"" %}
                ...
            {% else %}
                <a
                {% ifequal other_page previous %}
                    class=""previous""
                {% else %}{% ifequal other_page next %}
                    class=""next""
                {% endifequal %}{% endifequal %}
                href=""../{{ other_page }}/{% if querystring %}?{{ querystring|escape }}{% endif %}"">{{ other_page }}</a>
            {% endifequal %}{% endifequal %}
        {% endfor %}
    </div>
    <br style=""clear: right;"" />
{% endif %}
}}}

With a little css the above looks like this:
http://img292.imageshack.us/img292/9097/pagerp2.png

The second improvement this patch makes is that object_list now passes the already existing paginator attributes first_on_page and last_on_page so that the resulting page can say something like ""1 - 10 of 22"".

The third and final improvement is that as well as accepting querysets for the arguement queryset, queryset can now be a list, which is important if a view requires pagination but only has data not from a database, data from a database that has been processed or data from a database obtained via raw SQL.

I'm not sure if some of these improvements go against the django way, if they do then implement any of it that is django-y and leave out the rest."	enhancement	closed	Generic views	dev	normal	invalid			Unreviewed	1	0	0	0	0	0
