Use urlencode for querystring macro

This commit is contained in:
2026-03-28 14:32:08 +01:00
parent 2a9bb46e97
commit 71bfdf68b7

View File

@@ -124,8 +124,11 @@
This must be coupled with a view that handles pagination This must be coupled with a view that handles pagination
with the Django Paginator object. with the Django Paginator object.
Warning: Warnings:
You must include this macro `with context` as it uses the `querystring` macro This macro must be imported with context :
```jinja
{% from "core/macros.jinja" import paginate_jinja with context %}
```
Parameters: Parameters:
current_page (django.core.paginator.Page): the current page object current_page (django.core.paginator.Page): the current page object
@@ -142,8 +145,11 @@
The replaced fragment will be #content so make sure you are calling this macro inside your content block. The replaced fragment will be #content so make sure you are calling this macro inside your content block.
Warning: Warnings:
You must include this macro `with context` as it uses the `querystring` macro This macro must be imported with context :
```jinja
{% from "core/macros.jinja" import paginate_jinja with context %}
```
Parameters: Parameters:
current_page (django.core.paginator.Page): the current page object current_page (django.core.paginator.Page): the current page object
@@ -254,14 +260,7 @@
{% macro querystring() %} {% macro querystring() %}
{%- for key, values in request.GET.lists() -%} {%- set qs = request.GET.copy() -%}
{%- if key not in kwargs -%} {%- do qs.update(kwargs) -%}
{%- for value in values -%} {{- qs | urlencode -}}
{{ key }}={{ value }}&
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- for key, value in kwargs.items() -%}
{{ key }}={{ value }}&
{%- endfor -%}
{% endmacro %} {% endmacro %}