﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36268	"The querystring template tag should render an empty query string result as ""?"" instead of """""	Sarah Boyce	Natalia Bidart	"Test to demonstrate the issue:
{{{#!diff
--- a/tests/template_tests/syntax_tests/test_querystring.py
+++ b/tests/template_tests/syntax_tests/test_querystring.py
@@ -56,6 +56,13 @@ class QueryStringTagTests(SimpleTestCase):
                 self.assertRenderEqual(
                     ""test_querystring_empty_params"", context, expected=""""
                 )
+        request = self.request_factory.get(""/?a=1"")
+        for param in cases:
+            with self.subTest(param=param, url=""/?a=1""):
+                context = RequestContext(request, {""qd"": param})
+                self.assertRenderEqual(
+                    ""test_querystring_empty_params"", context, expected=""?""
+                )
 
     @setup({""querystring_replace"": ""{% querystring a=1 %}""})
}}}

In short, returning an empty string for querydict means that the page would not reload if this was used in a link, see #36182.
Therefore, it only makes sense to return an empty string when the query string that would be evaluated is equivalent to the current query string.

We are not supporting this in most cases e.g. if you are on `/?color=green` and in the template there is `{% querystring color=green %}` this evaluates to `""?color=green""` (not `""""`).

In the niche case that you are on `/?color=green` and pass in an empty query dict rather than the default `request.context.GET`, and render `{% querystring query_dict %}` this returns `""""` and so the page would not reload and you would stay on `/?color=green` even though you probably expected this to blitz the query string and take you to `/` (which would be the case if `""?""` was returned).
I think this is niche because there is no reason for you not to hard code the url in these cases as you don't care about the current query string

For simplicity, I think the proceeding ""?"" should always be returned.
I think the ""bug"" I described is unlikely to happen in the wild, I am classing this as a cleanup. Other thoughts are welcome."	Cleanup/optimization	closed	Template system	dev	Normal	fixed		David Feeley Tom Carrick Natalia Bidart	Ready for checkin	1	0	0	0	0	0
