One of the tasks that I seem to repeatedly do across multiple projects, is extend the built-in paginator from Django. The built-in is fairly nice, but it’s quite honestly extremely confusing as you have to pass around a paginator instance as well as a paginator.page() instance in order to get useful pagination inside of a template.
After the Nth time of someone coming up with questions about the paginator, and seeing Brian Rosner’s not-very-smart “smart_page_range” code (his words, not mine!), I figured it might be useful to throw this out to the public.