1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

[5.2.x] 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.

Backport of 05002c153c from main.
This commit is contained in:
Sarah Boyce
2025-02-12 17:08:03 +01:00
parent d3d9f3a5a4
commit 92d5b2f389
4 changed files with 23 additions and 9 deletions

View File

@@ -20,6 +20,18 @@ class QueryStringTagTests(SimpleTestCase):
"test_querystring_empty_get_params", context, expected=""
)
@setup({"test_querystring_remove_all_params": "{% querystring a=None %}"})
def test_querystring_remove_all_params(self):
non_empty_context = RequestContext(self.request_factory.get("/?a=b"))
empty_context = RequestContext(self.request_factory.get("/"))
for context, expected in [(non_empty_context, "?"), (empty_context, "")]:
with self.subTest(expected=expected):
self.assertRenderEqual(
"test_querystring_remove_all_params",
context,
expected,
)
@setup({"test_querystring_non_empty_get_params": "{% querystring %}"})
def test_querystring_non_empty_get_params(self):
request = self.request_factory.get("/", {"a": "b"})