#36270 closed New feature (needsinfo)
Allow removal of keys starting with a specific prefix in the querystring template tag.
Description ¶
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.
Change History (3)
comment:1 by , 3 days ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 2 days ago
Cc: | added |
---|---|
Resolution: | → needsinfo |
Status: | assigned → closed |
comment:3 by , 2 days ago
Summary: | Remove queries starting with a specific prefix from the querystring template tag. → Allow removal of keys starting with a specific prefix in the querystring template tag. |
---|
Note:
See TracTickets
for help on using tickets.
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 asneedsinfo
for now, but please reopen it once you can provide those details.Thank you again!