def paginate(request, queryset, per_page=20, count=None):
    p = (ESPaginator if isinstance(queryset, search.ES)
         else paginator.Paginator)(queryset, per_page)

    if count is not None:
        p._count = count

    # Get the page from the request, make sure it's an int.
    try:
        page = int(request.GET.get('page', 1))
    except ValueError:
        page = 1

    # Get a page of results, or the first page if there's a problem.
    try:
        paginated = p.page(page)
    except (paginator.EmptyPage, paginator.InvalidPage):
        paginated = p.page(1)

    paginated.url = u'%s?%s' % (request.path, request.GET.urlencode())
    return paginated
matches the old with new via TargetTagMap object.
dataset/ETHPy150Open mozilla/addons-server/src/olympia/amo/utils.py/paginate--crossover with--dataset/ETHPy150Open jesseward/discogstagger/discogstagger/taggerutils.py/TaggerUtils._get_tag_map