A ticket has already been created for this, but SmileyChris
recommended I bring the issue up here.
Working with pagination and query strings within a template can be
painful. Personally, I have never had a situation when I was
paginating using a GET parameter where there were not other parameters
that needed to be preserved through out the various pages.
Take search, for example. There may be parameters for searching within
one or more models, for a particular author and sorting by date.
Maintaining all of these parameters within the pagination links takes
some serious template logic.
{# Linebreaks added for readability. In real life this would need to
be one, long line. #}
<a href="?{% for key, values in request.GET.iterlists %}
{% ifnotequal key "page" %}
{% for value in values %}
{{ key }}={{ value }}&
{% endfor %}
{% endifnotequal %}
{% endfor %}page={{ page.next_page_number }}">Next page</a>
That kind of logic shouldn’t be in a template. I have created a patch
that would allow for something much simpler, like so:
<a href="?{{ page.next_page_querystring }}">Next page</a>
Though there has been much talk of creating template tags which would
produce all-out pagination bars, I believe this particular
functionality should be an actual method on the page object for two
reasons:
1. This is basic functionality whose end result is hard to dispute
(as opposed to a full pagination bar where markup and features could
be disputed eternally),
2. This does not require the request context processor to be
installed.
Note that this patch includes documentation. Tests are still needed. I
am not married to the exact implementation, but I and others I have
discussed this and feel that this simplicity and functionality belong
in Django’s pagination.
Ticket: http://code.djangoproject.com/ticket/10941
Patch:
http://code.djangoproject.com/attachment/ticket/10941/querystring-methods.diff
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.