(post_objects, request)
return post_objects, paginator, page_objects, page_range, current_page, show_first, show_end
page public function , return page's object tuple
    分页公用函数，返回分页的对象元组
page public function , return page's object tuple
    分页公用函数，返回分页的对象元组
page public function return page s object tuple 分页公用函数，返回分页的对象元组
def pages(post_objects, request):
    """
    page public function , return page's object tuple
    分页公用函数，返回分页的对象元组
    """
    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