Replaced django.template.defaultfilters.urlencode with django.utils.http.urlquote and removed unused import.