def make_paginator(request, items, per_page=50):
 try:
  page = int(request.GET.get('page', '1'))
 except ValueError:
  page = 1
 paginator = Paginator(items, per_page)
 try:
  items = paginator.page(page)
 except (InvalidPage, EmptyPage):
  items = paginator.page(paginator.num_pages)
 return items

def make_paginator ( request , items , per_page = 50 ) : try : page = int ( request . GET . get ( 'page' , '1' ) ) except ValueError : page = 1 paginator = Paginator ( items , per_page ) try : items = paginator . page ( page ) except ( InvalidPage , EmptyPage ) : items = paginator . page ( paginator . num_pages ) return items
make paginator .