I am having problems using pagination in [Django](http://en.wikipedia.org/wiki/Django_%28web_framework%29). Take the URL below as an example:

```
http://127.0.0.1:8000/users/?sort=first_name

```

On this page I sort a list of users by their first\_name. Without a sort GET variable it defaults to sort by id. 

Now if I click the next link I expect the following URL:

```
http://127.0.0.1:8000/users/?sort=first_name&page=2

```

Instead I lose all get variables and end up with 

```
http://127.0.0.1:8000/users/?page=2

```

This is a problem because the second page is sorted by id instead of first\_name.

If I use request.get\_full\_path I will eventually end up with an ugly URL:

```
http://127.0.0.1:8000/users/?sort=first_name&page=2&page=3&page=4

```

What is the solution? Is there a way to access the GET variables on the template and replace the value for the page?

I am using pagination as described in [Django's documentation](http://docs.djangoproject.com/en/dev/topics/pagination/) and my preference is to keep using it. The template code I am using is similar to this:

```
{% if contacts.has_next %}
    <a href="?page={{ contacts.next_page_number }}">next</a>
{% endif %}

```