« Painless Amazon EC2 Backup | Home | Google Gets Into VC Business »
Digg Style Pagination In Django Revisited
By Paul Kenjora | March 19, 2009
Months ago I wrote a Auto Adjusting Pagination As A Template Tag Plus Include post about a template tag that can paginate any result set on the fly producing a Digg style page widget. What is a Digg style page widget? Its pagination that breaks the list of pages into three dynamic groups. Left, middle, and right set of pages. For example…

This image was Google Image borrowed from Ryan Kanno
The advantage of this pagination implementation is that it only requires one template tag and one line of template code to work. No messy URLs to configure and no need to recode any of your existing parameters except adding a ?page=X for the current page.
The source download contains everything you need to implement this in about 5 minutes. Once you unpack the download, you will see:
- pagination_tag.py – The template tag that does all the computation. You will never need to modify this. Drop it into the templatetags directory, make sure theres an __init__.py in there.
- pagination.html – The template for the pagination widget. You probably don’t need to modify this because the CSS controls the look and feel. Drop this in your templates directory.
- pagination.css – The style sheet for the pagination widget. Modify this to match your site. Don’t forget to add it to your header.
- example.html – The minimum integration for the widget into any template. All the parameters are documented in the template tag file. This is what your template should look like to use this.
For those of you wondering how this works, on the left is probably close to the template you have today, it shows a simple list of objects you pulled from the database using a query. On the right is the same template with pagination added. This is how you modify the code you have to use this:
Original Template{% for item in items %} |
Paginated Template{% load pagination_tag %} |
The source download. Full Code Here!
This code has been taken up by MeoCode, see an updated and more detailed version here. Thanks MeoCode, enjoy!
More from Aware Labs
- Custom Actions In Django Admin Object Editor
- Everything A Django Developer Needs To Create Logins
- Auto Adjusting Pagination As A Template Tag Plus Include
- Digg For Django Is Here
- When Django Apps Grow Up
Aware Labs Recommends
Topics: Template Tags | Comments
-
rates
-
bob
-
pkenjora
-
Yehat
-
pkenjora
-
Yehat
-
meppum
-
guest
-
john
-
miami web design
-
UnhappyJoe
-
pkenjora
-
UnhappyJoe
-
pkenjora
-
UnhappyJoe
-
Pete
-
Red Wine
-
meppum
-
Olejek Rokitnikowy
-
frustrateduser
-
pkenjora
-
rollenc
-
corsairmoran
-
MeowCode
-
MeowCode
-
john
-
MeowCode
-
MeowCode