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

Function urlencode

django/template/defaultfilters.py:367–379  ·  view source on GitHub ↗

Escape a value for use in a URL. The ``safe`` parameter determines the characters which should not be escaped by Python's quote() function. If not provided, use the default safe characters (but an empty string can be provided when *all* characters should be escaped).

(value, safe=None)

Source from the content-addressed store, hash-verified

365@register.filter(is_safe=False)
366@stringfilter
367def urlencode(value, safe=None):
368 """
369 Escape a value for use in a URL.
370
371 The ``safe`` parameter determines the characters which should not be
372 escaped by Python's quote() function. If not provided, use the default safe
373 characters (but an empty string can be provided when *all* characters
374 should be escaped).
375 """
376 kwargs = {}
377 if safe is not None:
378 kwargs["safe"] = safe
379 return quote(value, **kwargs)
380
381
382@register.filter(is_safe=True, needs_autoescape=True)

Callers 4

test_urlencodeMethod · 0.90
test_non_string_inputMethod · 0.90
test_urlencodedMethod · 0.90
normalizeMethod · 0.50

Calls 1

quoteFunction · 0.85

Tested by 4

test_urlencodeMethod · 0.72
test_non_string_inputMethod · 0.72
test_urlencodedMethod · 0.72
normalizeMethod · 0.40