diff options
| author | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-02-12 17:08:03 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-02-13 15:49:25 +0100 |
| commit | 05002c153c5018e4429a326a6699c7c45e5ea957 (patch) | |
| tree | 89c871eb639ab50a15676bcca21a806e784e7a3e /django/template | |
| parent | 0ee842bb456cb3854d5546106e1259db83714d34 (diff) | |
Fixed #36182 -- Returned "?" if all parameters are removed in querystring template tag.
Thank you to David Feeley for the report and Natalia Bidart for the review.
Diffstat (limited to 'django/template')
| -rw-r--r-- | django/template/defaulttags.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index ae74679ec6..1152452081 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -1194,18 +1194,18 @@ def querystring(context, query_dict=None, **kwargs): """ if query_dict is None: query_dict = context.request.GET - query_dict = query_dict.copy() + params = query_dict.copy() for key, value in kwargs.items(): if value is None: - if key in query_dict: - del query_dict[key] + if key in params: + del params[key] elif isinstance(value, Iterable) and not isinstance(value, str): - query_dict.setlist(key, value) + params.setlist(key, value) else: - query_dict[key] = value - if not query_dict: + params[key] = value + if not params and not query_dict: return "" - query_string = query_dict.urlencode() + query_string = params.urlencode() return f"?{query_string}" |
