@register_tag<EOL>def get_query_params(request, *args):
query = request.GET.copy()<EOL>index = <NUM_LIT:1><EOL>key = '<STR_LIT>'<EOL>for arg in args:<EOL><INDENT>if index % <NUM_LIT:2> != <NUM_LIT:0>:<EOL><INDENT>key = arg<EOL><DEDENT>else:<EOL><INDENT>if arg == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>query.pop(key)<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>query[key] = arg<EOL><DEDENT><DEDENT>index += <NUM_LIT:1><EOL><DEDENT>return query.urlencode()<EOL>
Allows to change one of the URL get parameter while keeping all the others.

Usage::

  {% load libs_tags %}
  {% get_query_params request "page" page_obj.next_page_number as query %}
  <a href="?{{ query }}">Next</a>

You can also pass in several pairs of keys and values::

  {% get_query_params request "page" 1 "foobar" 2 as query %}

You often need this when you have a paginated set of objects with filters.

Your url would look something like ``/?region=1&gender=m``. Your paginator
needs to create links with ``&page=2`` in them but you must keep the
filter values when switching pages.

:param request: The request instance.
:param *args: Make sure to always pass in paris of args. One is the key,
  one is the value. If you set the value of a key to "!remove" that
  parameter will not be included in the returned query.