Re: [Django] #36182: querystring templatetag should render empty querystring as "?" not "" when it has removed items from the querydict

13 views
Skip to first unread message

Django

unread,
Feb 11, 2025, 3:34:07 AMFeb 11
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: querystring | Triage Stage: Accepted
templatetag |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tom Carrick):

Seems like we should do something here.

So for only when it's changed, because if nothing has changed, you would
expect it to reload? I think I agree with that line of reasoning though I
haven't spent any time thinking about possible use cases and edge cases.
--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 11, 2025, 4:00:00 AMFeb 11
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: querystring | Triage Stage: Accepted
templatetag |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce):

> {% querystring %}
>
> Outputs the current query string verbatim. So if the query string is
?color=green, the output would be ?color=green.

I guess specifically, I did not expect the test
`template_tests.syntax_tests.test_querystring.QueryStringTagTests.test_querystring_empty_get_params`
to now return `"?"` instead of `""`. But perhaps there's no real advantage
of keeping the url the same?
--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:3>

Django

unread,
Feb 11, 2025, 11:49:40 AMFeb 11
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: querystring | Triage Stage: Accepted
templatetag |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by David Feeley):

Replying to [comment:3 Sarah Boyce]:
> > {% querystring %}
> >
> > Outputs the current query string verbatim. So if the query string is
?color=green, the output would be ?color=green.
>
> I guess specifically, I did not expect the test
`template_tests.syntax_tests.test_querystring.QueryStringTagTests.test_querystring_empty_get_params`
to now return `"?"` instead of `""`. But perhaps there's no real advantage
of keeping the url the same?

I like your addition of the has_removed condition as I think rewriting an
empty query string ("") to "?" more generally probably violates the
principle of least surprise -- ie. why rewrite it when there is no need
to.
--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:4>

Django

unread,
Feb 12, 2025, 11:09:42 AMFeb 12
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: Sarah
| Boyce
Type: Bug | Status: assigned
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: querystring | Triage Stage: Accepted
templatetag |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* has_patch: 0 => 1
* owner: (none) => Sarah Boyce
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:5>

Django

unread,
Feb 13, 2025, 8:30:29 AMFeb 13
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: Sarah
| Boyce
Type: Bug | Status: assigned
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: querystring | Triage Stage: Ready for
templatetag | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:6>

Django

unread,
Feb 13, 2025, 9:49:35 AMFeb 13
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: Sarah
| Boyce
Type: Bug | Status: closed
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution: fixed
Keywords: querystring | Triage Stage: Ready for
templatetag | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"05002c153c5018e4429a326a6699c7c45e5ea957" 05002c15]:
{{{#!CommitTicketReference repository=""
revision="05002c153c5018e4429a326a6699c7c45e5ea957"
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:7>

Django

unread,
Feb 13, 2025, 9:51:38 AMFeb 13
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: Sarah
| Boyce
Type: Bug | Status: closed
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution: fixed
Keywords: querystring | Triage Stage: Ready for
templatetag | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"92d5b2f389314f12ad3f5c192e9c56a3938b2b32" 92d5b2f3]:
{{{#!CommitTicketReference repository=""
revision="92d5b2f389314f12ad3f5c192e9c56a3938b2b32"
[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 05002c153c5018e4429a326a6699c7c45e5ea957 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:8>

Django

unread,
Feb 13, 2025, 9:59:12 AMFeb 13
to django-...@googlegroups.com
#36182: querystring templatetag should render empty querystring as "?" not "" when
it has removed items from the querydict
-------------------------------------+-------------------------------------
Reporter: David Feeley | Owner: Sarah
| Boyce
Type: Bug | Status: closed
Component: Template system | Version: 5.1
Severity: Release blocker | Resolution: fixed
Keywords: querystring | Triage Stage: Ready for
templatetag | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"65113401f1f6786f8a89dfcb7d0347924b317e7b" 6511340]:
{{{#!CommitTicketReference repository=""
revision="65113401f1f6786f8a89dfcb7d0347924b317e7b"
[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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36182#comment:9>
Reply all
Reply to author
Forward
0 new messages