Escapes a string for use in a URL.
Variable
url = 'https://www.webucator.com/search/search.cfm?q=django'
Template
{{ url|urlencode }}
Result
https%3A//www.webucator.com/search/search.cfm%3Fq%3Ddjango
Forward slashes (/) are not escaped by default. To escape all special characters, pass an empty string ("") for the argument.
Additional Examples
{{ url|urlencode:"/" }}
{{ url|urlencode:"" }}
{{ url|urlencode:":" }}
Results
https%3A//www.webucator.com/search/search.cfm%3Fq%3Ddjango https%3A%2F%2Fwww.webucator.com%2Fsearch%2Fsearch.cfm%3Fq%3Ddjango https:%2F%2Fwww.webucator.com%2Fsearch%2Fsearch.cfm%3Fq%3Ddjango

Commentary
The
urlencodefilter can be used for passing URL parameters back to the querystring in generated links. For example:<a href="?page=1&ordering={{ request.GET.ordering|urlencode }}">1</a>