@register.simple_tag
def query_transform(request, **kwargs):
    updated = request.GET.copy()
for k, v in kwargs.items():
    updated[k] = v
return updated.urlencode()
How to add the current query string to an URL in a Django template?