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

Method urlencode

django/http/request.py:712–742  ·  django/http/request.py::QueryDict.urlencode

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 class="st">"""
714 Return an encoded string of all query string arguments.
715
716 `safe` specifies characters which don&class="cm">#x27;t require quoting, for example::
717
718 >>> q = QueryDict(mutable=True)
719 >>> q[&class="cm">#x27;nextclass="st">'] = '/a&b/'
720 >>> q.urlencode()
721 &class="cm">#x27;next=%2Fa%26b%2F'
722 >>> q.urlencode(safe=&class="cm">#x27;/')
723 &class="cm">#x27;next=/a%26b/'
724 class="st">"""
725 output = []
726 if safe:
727 safe = safe.encode(self.encoding)
728
729 def encode(k, v):
730 return class="st">"%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 class="st">"&".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