From 65113401f1f6786f8a89dfcb7d0347924b317e7b Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Wed, 12 Feb 2025 17:08:03 +0100 Subject: [5.1.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 05002c153c5018e4429a326a6699c7c45e5ea957 from main. --- tests/template_tests/syntax_tests/test_querystring.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/template_tests/syntax_tests/test_querystring.py') diff --git a/tests/template_tests/syntax_tests/test_querystring.py b/tests/template_tests/syntax_tests/test_querystring.py index 3f1cf3d281..099be96f9e 100644 --- a/tests/template_tests/syntax_tests/test_querystring.py +++ b/tests/template_tests/syntax_tests/test_querystring.py @@ -17,6 +17,15 @@ class QueryStringTagTests(SimpleTestCase): output = template.render(context) self.assertEqual(output, "") + @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("/")) + template = self.engine.get_template("test_querystring_remove_all_params") + for context, expected in [(non_empty_context, "?"), (empty_context, "")]: + with self.subTest(expected=expected): + self.assertEqual(template.render(context), expected) + @setup({"querystring_non_empty": "{% querystring %}"}) def test_querystring_non_empty(self): request = self.request_factory.get("/", {"a": "b"}) -- cgit v1.3