def get_html_context(self):
        base_url = self.request.build_absolute_uri()
        current = _divide_with_ceil(self.offset, self.limit) + 1
        # The number of pages is a little bit fiddly.
        # We need to sum both the number of pages from current offset to end
        # plus the number of pages up to the current offset.
        # When offset is not strictly divisible by the limit then we may
        # end up introducing an extra page as an artifact.
        final = (
            _divide_with_ceil(self.count - self.offset, self.limit) +
            _divide_with_ceil(self.offset, self.limit)
        )
        if final < 1:
            final = 1

        if current > final:
            current = final

        def page_number_to_url(page_number):
            if page_number == 1:
                return remove_query_param(base_url, self.offset_query_param)
            else:
                offset = self.offset + ((page_number - current) * self.limit)
                return replace_query_param(base_url, self.offset_query_param, offset)

        page_numbers = _get_displayed_page_numbers(current, final)
        page_links = _get_page_links(page_numbers, current, page_number_to_url)

        return {
            'previous_url': self.get_previous_link(),
            'next_url': self.get_next_link(),
            'page_links': page_links
        }
dataset/ETHPy150Open tomchristie/django-rest-framework/rest_framework/pagination.py/LimitOffsetPagination.get_html_context/original