unquote is a callable within the django.utils.http module of the Django project.
django-angular (project examples website) is a library with helper code to make it easier to use Angular as the front-end to Django projects. The code for django-angular is open source under the MIT license.
django-angular / djng / middleware.py
# middleware.py
from django import http
from django.urls import reverse
from django.utils.http import unquote
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
class AngularUrlMiddleware(MiddlewareMixin):
ANGULAR_REVERSE = '/angular/reverse/'
def process_request(self, request):
if request.path == self.ANGULAR_REVERSE:
url_name = request.GET.get('djng_url_name')
url_args = request.GET.getlist('djng_url_args', [])
url_kwargs = {}
url_args = filter(lambda x: x, url_args)
for param in request.GET:
if param.startswith('djng_url_kwarg_'):
if request.GET[param]:
url_kwargs[param[15:]] = request.GET[param] # [15:] to remove 'djng_url_kwarg' prefix
url = unquote(reverse(url_name, args=url_args, kwargs=url_kwargs))
assert not url.startswith(self.ANGULAR_REVERSE), "Prevent recursive requests"
request.path = request.path_info = url
request.environ['PATH_INFO'] = url
query = request.GET.copy()
for key in request.GET:
if key.startswith('djng_url'):
query.pop(key, None)
request.environ['QUERY_STRING'] = query.urlencode()
request.GET = http.QueryDict(request.environ['QUERY_STRING'])
## ... source file continues with no further unquote examples...