#35523: query_string cannot use variables as keys
-------------------------------------------+------------------------
Reporter: Sarah Boyce | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 5.1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
Raised by Florian here: https://forum.djangoproject.com/t/adding-a
-template-tag-to-generate-query-strings/24521/15
If we are to add a test:
{{{#!diff
--- a/tests/template_tests/syntax_tests/test_query_string.py
+++ b/tests/template_tests/syntax_tests/test_query_string.py
@@ -98,3 +98,16 @@ class QueryStringTagTests(SimpleTestCase):
msg = "'Context' object has no attribute 'request'"
with self.assertRaisesMessage(AttributeError, msg):
self.engine.render_to_string("query_string_no_request_no_query_dict")
+
+ @setup(
+ {
+ "query_string_var_key": '{% with key="var_key" %}{%
query_string key=2 %}'
+ "{% endwith %}"
+ }
+ )
+ def test_query_string_with_variable_key(self):
+ request = self.request_factory.get("/")
+ template = self.engine.get_template("query_string_var_key")
+ context = RequestContext(request)
+ output = template.render(context)
+ self.assertEqual(output, "?var_key=2")
}}}
This fails with `AssertionError: '?key=2' != '?var_key=2'`.
One suggestion is to quote literal keys eg. `{% query_string var_key=1
'other_key'=2 %}`
Refs #10941, design decision required, potential release blocker
--
Ticket URL: <https://code.djangoproject.com/ticket/35523>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107019010934c97-e63d9cce-cc16-4abc-891c-a39aecd23e1c-000000%40eu-central-1.amazonses.com.