How to use Django {% querystring %} with GET form?

In Django 5.1 {% querystring %} was added. Is there some way to use it with GET form?

For example, let's say we have template with:

<span>Paginate by:</span>
<a href="{% querystring paginate_by=50 %}">50</a>

{# ... #}

<form method="GET">
    <input name="query" value="{{ request.GET.query }}">

    <button type="submit">Search</button>
</form>

Assuming that we are currently on localhost:8000/?paginate_by=50, how to change form so clicking Search won't delete paginate_by query parameter - so what I want is for example localhost:8000/?paginate_by=50&query=abc and not localhost:8000/?query=abc?

Before 5.1 I handled that via providing form with hidden fields based on GET parameters, but I am hoping that now more elegant solution is possible.

Вернуться на верх