def get_querystring_for_page(request, page_number, querystring_key,
    default_number=1, prefix="?"):
    """
    Return a querystring pointing to *page_number*.
    The querystring is prefixed by *prefix* (e.g.: "?page=2").
    """
    querydict = request.GET.copy()
    querydict[querystring_key] = page_number
    # for page number 1 there is no need for querystring
    if page_number == default_number:
        del querydict[querystring_key]
    if "querystring_key" in querydict:
        del querydict["querystring_key"]
    if querydict:
        return "%s%s" % (prefix, querydict.urlencode())
    return ""