A New (Better?) Django Pagination Middleware and Popular Pagination Styles
Quick tip.
Pagination in Django is a matter of preference. While there are built in classes, using them can require retooling of URLs, views, and templates. The preferred method is to use middleware as it is usually less invasive.
The most widely used pagination middleware is django-pagination. It works by appending a query string value to keep track of the current page and modifies the designated queries to retrieve only the relevant data. This method is elegant, however, due to its reliance on query string parameters it is not currently supported by the built in django page cache.
I found an alternative pagination middleware that is *almost* as non-invasive as the aforementioned pagination middleware, and does not rely on query string parameters, but instead uses pretty URLs (e.g. /page/1/).
I also stumbled upon a collection of CSS classes emulating popular pagination styles. The only rub is that the the markup in the pagination template provided by my new favorite pagination class doesn't match any of the CSS classes.
I modified the template. Hopefully, it will save someone a little time. You can find it here.
blog comments powered by Disqus