code: def url_replace_param(url, name, value):
      
      url_components = urlparse(force_str(url))
      query_params = parse_qs(url_components.query)
      query_params[name] = value
      query = urlencode(query_params, doseq=True)
      return force_text(
          urlunparse(
              [
                  url_components.scheme,
                  url_components.netloc,
                  url_components.path,
                  url_components.params,
                  query,
                  url_components.fragment,
              ]
          )
      )
docs: Replace a GET parameter in an URL