Starting from Django 5.1 there is a dedicated template tag querystring
Basic usage:
{% querystring size="M" %}