def get_elastic_page_numbers(current_page, num_pages):
    if num_pages <= 10:
        return list(range(1, num_pages + 1))
    if current_page == 1:
        pages = [1]
    else:
        pages = ['first', 'previous']
        pages.extend(_make_elastic_range(1, current_page))
    if current_page != num_pages:
        pages.extend(_make_elastic_range(current_page, num_pages)[1:])
        pages.extend(['next', 'last'])
    return pages
Alternative callable for page listing.
dataset/ETHPy150Open frankban/django-endless-pagination/endless_pagination/utils.py/get_elastic_page_numbers