🚀 Feature Friday: {% querystring %} !

The new {% querystring %} template tag in Django 5.1 makes it easier to access and modify the query string in your Django templates, letting you work with links that use query parameters.

🧵 (1/3)
#Django #DjangoFeatureFriday

Previously, if you wanted to add or change a single value in the query string, you would need to write a lot of code.

Using {% querystring %} you can replace all code in the below screenshot with this line:

{% querystring page=page.next_page_number %}

🧵 (2/3)

{% querystring %} is particularly useful for things like filters and pagination—where you want to pass through most of the query parameters but modify one or two. You can add, remove, and modify query params, all from a single place!

Docs: https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#std-templatetag-querystring

🧵 (3/3)

Built-in template tags and filters | Django documentation

The web framework for perfectionists with deadlines.

Django Project