#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.