[Django] #36270: Remove queries starting with a specific prefix from the querystring template tag.

2 views
Skip to first unread message

Django

unread,
Mar 20, 2025, 7:35:15 PM3/20/25
to django-...@googlegroups.com
#36270: Remove queries starting with a specific prefix from the querystring
template tag.
-----------------------------+-------------------------------------------
Reporter: Antoliny | Type: New feature
Status: new | Component: Template system
Version: dev | Severity: Normal
Keywords: querystring | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+-------------------------------------------
I think it would be great if the querystring template tag also had a
feature to remove all queries that start with a specific prefix.
I believe adding a feature that removes all queries starting with a
specific prefix would be useful when excluding certain items from filtered
query parameters.
{{{
class ChangeList:
...
def get_query_string(self, new_params=None, remove=None):
if new_params is None:
new_params = {}
if remove is None:
remove = []
p = self.filter_params.copy()
for r in remove:
for k in list(p):
if k.startswith(r):
del p[k]
for k, v in new_params.items():
if v is None:
if k in p:
del p[k]
else:
p[k] = v
return "?%s" % urlencode(sorted(p.items()), doseq=True)
}}}
This feature is actually one of the functionalities provided by the
`get_query_string` method in the `ChangeList` class, which serves almost
the same purpose as querystring template tag.
--
Ticket URL: <https://code.djangoproject.com/ticket/36270>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2025, 7:35:29 PM3/20/25
to django-...@googlegroups.com
#36270: Remove queries starting with a specific prefix from the querystring
template tag.
---------------------------------+--------------------------------------
Reporter: Antoliny | Owner: Antoliny
Type: New feature | Status: assigned
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: querystring | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Antoliny):

* owner: (none) => Antoliny
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36270#comment:1>

Django

unread,
Mar 21, 2025, 8:31:40 AM3/21/25
to django-...@googlegroups.com
#36270: Remove queries starting with a specific prefix from the querystring
template tag.
---------------------------------+--------------------------------------
Reporter: Antoliny | Owner: Antoliny
Type: New feature | Status: closed
Component: Template system | Version: dev
Severity: Normal | Resolution: needsinfo
Keywords: querystring | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Natalia Bidart):

* cc: David Feeley, Tom Carrick (added)
* resolution: => needsinfo
* status: assigned => closed

Comment:

Hello Antoliny, thank you for taking the time to create the ticket!

I can see the use case in the admin, but to be honest, this feels somewhat
like an antipattern when considering the `querystring` template tag in
isolation. Before completing the triage, could you share how you envision
integrating this feature into the current syntax? I'll mark this as
`needsinfo` for now, but please reopen it once you can provide those
details.

Thank you again!
--
Ticket URL: <https://code.djangoproject.com/ticket/36270#comment:2>
Reply all
Reply to author
Forward
0 new messages