Opened 9 months ago
Last modified 3 weeks ago
#35529 assigned New feature
Have the template tag query_string support Mapping[str, Any] as an argument — at Version 1
Reported by: | Sarah Boyce | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | 18368 build:success | ||
Description (last modified by ) ¶
Based off this discussion: https://forum.djangoproject.com/t/adding-a-template-tag-to-generate-query-strings/24521/28
Currenty query_string
only supports a QueryDict
as an argument, consensus appears to want to update this to also support Mapping[str, Any]
-
TabularUnified tests/template_tests/syntax_tests/test_query_string.py
a b class QueryStringTagTests(SimpleTestCase): 93 93 ) 94 94 self.assertEqual(output, "?a=2&b=2") 95 95 96 @setup( 97 {"query_string_dict": "{% query_string my_dict %}"} 98 ) 99 def test_query_string_with_explicit_query_dict_and_no_request(self): 100 context = {"my_dict": {"a": 1, "b": 2}} 101 output = self.engine.render_to_string("query_string_dict", context) 102 self.assertEqual(output, "?a=1&b=2") 103 96 104 @setup({"query_string_no_request_no_query_dict": "{% query_string %}"}) 97 105 def test_query_string_without_request_or_explicit_query_dict(self): 98 106 msg = "'Context' object has no attribute 'request'"
Note: I believe this is backwards compatible so not a release blocker
According to the ticket's flags, the next step(s) to move this issue forward are:
- To improve the patch as described in the pull request review comments or on this ticket, then uncheck "Patch needs improvement".
If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.