path_with_added_args now works with multiple existing args

This commit is contained in:
Simon Willison 2018-05-14 19:09:09 -03:00 committed by Simon Willison
commit 8a4ed052a5
2 changed files with 5 additions and 2 deletions

View file

@ -149,10 +149,10 @@ def path_with_added_args(request, args, path=None):
path = path or request.path
if isinstance(args, dict):
args = args.items()
arg_keys = set(a[0] for a in args)
args_to_remove = {k for k, v in args if v is None}
current = []
for key, value in urllib.parse.parse_qsl(request.query_string):
if key not in arg_keys:
if key not in args_to_remove:
current.append((key, value))
current.extend([
(key, value)