def lfs_pagination(request, current_page, url='', getparam='start'):
    paginator = current_page.paginator
    current_page_no = current_page.number

    has_next = current_page.has_next()
    has_prev = current_page.has_previous()

    page_range = define_page_range(current_page.number, paginator.num_pages)

    first = 1
    last = paginator.num_pages

    if first in page_range:
        first = None

    if last in page_range:
        last = None

    to_return = {'page_range': page_range,
                 'current_page': current_page_no,
                 'total_pages': paginator.num_pages,
                 'has_next': has_next,
                 'has_prev': has_prev,
                 'next': current_page_no + 1,
                 'prev': current_page_no - 1,
                 'url': url,
                 'getparam': getparam,
                 'first_page': first,
                 'last_page': last,
                 'getvars': ''
                }

    getvars = request.GET.copy()
    if getparam in getvars:
        del getvars[getparam]
    if len(getvars.keys()) > 0:
        to_return['getvars'] = "&%s" % getvars.urlencode()
    return to_return
Prepare data for pagination
dataset/ETHPy150Open diefenbach/django-lfs/lfs/core/utils.py/lfs_pagination