MCPcopy
hub / github.com/django/django / urlencode

Method urlencode

django/http/request.py:712–742  ·  view source on GitHub ↗

Return an encoded string of all query string arguments. `safe` specifies characters which don't require quoting, for example:: >>> q = QueryDict(mutable=True) >>> q['next'] = '/a&b/' >>> q.urlencode() 'next=%2Fa%26b%2F' >

(self, safe=None)

Source from the content-addressed store, hash-verified

710 return self.__deepcopy__({})
711
712 def urlencode(self, safe=None):
713 """
714 Return an encoded string of all query string arguments.
715
716 `safe` specifies characters which don't require quoting, for example::
717
718 >>> q = QueryDict(mutable=True)
719 >>> q['next'] = '/a&b/'
720 >>> q.urlencode()
721 'next=%2Fa%26b%2F'
722 >>> q.urlencode(safe='/')
723 'next=/a%26b/'
724 """
725 output = []
726 if safe:
727 safe = safe.encode(self.encoding)
728
729 def encode(k, v):
730 return "%s=%s" % ((quote(k, safe), quote(v, safe)))
731
732 else:
733
734 def encode(k, v):
735 return urlencode({k: v})
736
737 for k, list_ in self.lists():
738 output.extend(
739 encode(k.encode(self.encoding), str(v).encode(self.encoding))
740 for v in list_
741 )
742 return "&".join(output)
743
744
745class MediaType:

Callers 12

redirect_to_loginFunction · 0.95
querystringFunction · 0.95
test_single_key_valueMethod · 0.95
test_urlencodeMethod · 0.95
test_urlencode_intMethod · 0.95
get_preserved_filtersMethod · 0.80
reverseFunction · 0.80
github_requestFunction · 0.80
test_httprequestMethod · 0.80

Calls 4

listsMethod · 0.80
extendMethod · 0.80
encodeMethod · 0.45
joinMethod · 0.45

Tested by 7

test_single_key_valueMethod · 0.76
test_urlencodeMethod · 0.76
test_urlencode_intMethod · 0.76
test_httprequestMethod · 0.64