What’s the best way to exclude parameters from request.GET?
eg, given a url param ?a=a&b=b&c=c and I want to take out param b to generate url param to ?a=a&c=c without changing request.GET
Right now I am looping through the keys to take out b
params = {}
for key,value in request.GET.items():
if not key == 'b':
params[key] = value
url = urllib.urlencode(params)
I am wondering if there is a better, more elegant way to achieve the same result? eg.
request.GET.urlencode(exclude=['b',])
or even this, better
urllib.urlencode(request.GET.exclude('b'...)
This should work: