def pages(post_objects, request):
 paginator = Paginator(post_objects, 20)
 try:
  current_page = int(request.GET.get('page', '1'))
 except ValueError:
  current_page = 1
 page_range = page_list_return(len(paginator.page_range), current_page)
 try:
  page_objects = paginator.page(current_page)
 except (EmptyPage, InvalidPage):
  page_objects = paginator.page(paginator.num_pages)
 if (current_page >= 5):
  show_first = 1
 else:
  show_first = 0
 if (current_page <= (len(paginator.page_range) - 3)):
  show_end = 1
 else:
  show_end = 0
 return (post_objects, paginator, page_objects, page_range, current_page, show_first, show_end)

def pages ( post_objects , request ) : paginator = Paginator ( post_objects , 20 ) try : current_page = int ( request . GET . get ( 'page' , '1' ) ) except ValueError : current_page = 1 page_range = page_list_return ( len ( paginator . page_range ) , current_page ) try : page_objects = paginator . page ( current_page ) except ( EmptyPage , InvalidPage ) : page_objects = paginator . page ( paginator . num_pages ) if ( current_page >= 5 ) : show_first = 1 else : show_first = 0 if ( current_page <= ( len ( paginator . page_range ) - 3 ) ) : show_end = 1 else : show_end = 0 return ( post_objects , paginator , page_objects , page_range , current_page , show_first , show_end )
page public function .