home / django_tickets / tickets

tickets: 10941

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
10941 2009-04-28 00:57:52 2021-12-17 18:17:32 2022-03-06 03:48:39.372625 Accepted new Template system New feature Normal dev   Add a templatetag to generate querystrings 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 }}&amp; {% 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 fuctionality belong in Django’s pagination.   benspaulding pagination 0 0 0 0 0 0
Powered by Datasette · Queries took 2.024ms