Skip to content

Instantly share code, notes, and snippets.

@anishmenon
Created February 1, 2016 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anishmenon/b4d38d2c9c8091ccb0c3 to your computer and use it in GitHub Desktop.
Save anishmenon/b4d38d2c9c8091ccb0c3 to your computer and use it in GitHub Desktop.
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
paginator = Paginator(customers, 30)
page = rg('page')
try:
customers = paginator.page(page)
except PageNotAnInteger:
customers = paginator.page(1)
except EmptyPage:
customers = paginator.page(paginator.num_pages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment