code: def paginate_queryset(self, queryset, page_size):
          
          paginator = self.get_paginator(
              queryset,
              page_size,
              orphans = self.get_paginate_orphans(),
              allow_empty_first_page = self.get_allow_empty(),
              body    = self.paginator_body,
              margin  = self.paginator_margin,
              padding = self.paginator_padding,
              tail    = self.paginator_tail,
          )
          page_kwarg = self.page_kwarg
          page = self.kwargs.get(page_kwarg) or self.request.GET.get(page_kwarg) or 1
          try:
              page_number = int(page)
          except ValueError:
              if page == 'last':
                  page_number = paginator.num_pages
              else:
                  raise Http404(_("Page is not 'last', nor can it be converted to an int."))
          try:
              page = paginator.page(page_number, softlimit=False)
              return (paginator, page, page.object_list, page.has_other_pages())
          except InvalidPage as e:
              raise Http404(_('Invalid page (%(page_number)s): %(message)s') % {
                  'page_number': page_number,
                  'message': str(e)
              })
docs: Paginate the queryset, if needed.
  
          This is EXACTLY the same as the standard ListView.paginate_queryset()
          except for this line:
              page = paginator.page(page_number, softlimit=True)
          Because we want to use the DiggPaginator's softlimit option.
          So that if you're viewing a page of, say, Flickr photos, and you switch
          from viewing by Uploaded Time to viewing by Taken Time, the new
          ordering might have fewer pages. In that case we want to see the final
          page, not a 404. The softlimit does that, but I can't see how to use
          it without copying all of this...