@register.inclusion_tag('datagrid/paginator.html', takes_context=True)
def paginator(context, adjacent_pages=3):
    page_nums = range(max(1, context['page'] - adjacent_pages),
                      min(context['pages'], context['page'] + adjacent_pages)
                      + 1)
    getvars = {}
    if 'request' in context:
        request = context['request']
        getvars = request.GET.copy()
        if 'page' in getvars:
            getvars['page']
    getvars = urllib.urlencode(getvars)

    return {
        'hits': context['hits'],
        'results_per_page': context['results_per_page'],
        'page': context['page'],
        'pages': context['pages'],
        'page_numbers': page_nums,
        'next': context['next'],
        'previous': context['previous'],
        'has_next': context['has_next'],
        'has_previous': context['has_previous'],
        'show_first': 1 not in page_nums,
        'show_last': context['pages'] not in page_nums,
        'extra_query': context.get('extra_query', None),
        'getvars': getvars,
    }
Renders a paginator used for jumping between pages of results.
dataset/ETHPy150Open agiliq/django-datagrid/datagrid/templatetags/datagrid.py/paginator