      """
      (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url))
      query_dict = urlparse.parse_qs(query, keep_blank_values=True)
      query_dict.pop(key, None)
      query = urlparse.urlencode(sorted(list(query_dict.items())), doseq=True)
      return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
 
</s> remove     (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url))
    query_dict = urlparse.parse_qs(query, keep_blank_values=True)
 </s> add     (scheme, netloc, path, query, fragment) = parse.urlsplit(force_str(url))
    query_dict = parse.parse_qs(query, keep_blank_values=True) </s> remove     query = urlparse.urlencode(sorted(list(query_dict.items())), doseq=True)
    return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
 </s> add     query = parse.urlencode(sorted(list(query_dict.items())), doseq=True)
    return parse.urlunsplit((scheme, netloc, path, query, fragment)) </s> remove     (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url))
    query_dict = urlparse.parse_qs(query, keep_blank_values=True)
 </s> add     (scheme, netloc, path, query, fragment) = parse.urlsplit(force_str(url))
    query_dict = parse.parse_qs(query, keep_blank_values=True) </s> remove         response = super(APIClient, self).patch(
 </s> add         response = super().patch( </s> remove         response = super(APIClient, self).post(
 </s> add         response = super().post(
    query = parse.urlencode(sorted(list(query_dict.items())), doseq=True)
    return parse.urlunsplit((scheme, netloc, path, query, fragment))
      """
      (scheme, netloc, path, query, fragment) = urlparse.urlsplit(force_str(url))
      query_dict = urlparse.parse_qs(query, keep_blank_values=True)
      query_dict.pop(key, None)
    query = parse.urlencode(sorted(list(query_dict.items())), doseq=True)
    return parse.urlunsplit((scheme, netloc, path, query, fragment))
    query = parse.urlencode(sorted(list(query_dict.items())), doseq=True)
    return parse.urlunsplit((scheme, netloc, path, query, fragment))
keep keep keep keep replace replace
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
rest_framework/utils/urls.py