[Answer]-Add or replace a parameter in the query string

1👍

request.GET is is the query string, and it conforms to the dictionary interface. As with all Python containers, an empty dict is False in a boolean context. So you can check if it’s empty by just doing if request.GET.

However, in your examples it seems you’re always replacing param1 anyway, do there is no need to check it first: just set the value: request.GET['param1'] = 'whatever'.

Leave a comment