MCPcopy
hub / github.com/django/django / process_view

Method process_view

django/contrib/admindocs/middleware.py:14–33  ·  view source on GitHub ↗

If the request method is HEAD and either the IP is internal or the user is a logged-in staff member, return a response with an x-view header indicating the view function. This is used to lookup the view function for an arbitrary page.

(self, request, view_func, view_args, view_kwargs)

Source from the content-addressed store, hash-verified

12 """
13
14 def process_view(self, request, view_func, view_args, view_kwargs):
15 """
16 If the request method is HEAD and either the IP is internal or the
17 user is a logged-in staff member, return a response with an x-view
18 header indicating the view function. This is used to lookup the view
19 function for an arbitrary page.
20 """
21 if not hasattr(request, "user"):
22 raise ImproperlyConfigured(
23 "The XView middleware requires authentication middleware to "
24 "be installed. Edit your MIDDLEWARE setting to insert "
25 "'django.contrib.auth.middleware.AuthenticationMiddleware'."
26 )
27 if request.method == "HEAD" and (
28 request.META.get("REMOTE_ADDR") in settings.INTERNAL_IPS
29 or (request.user.is_active and request.user.is_staff)
30 ):
31 response = HttpResponse()
32 response.headers["X-View"] = get_view_name(view_func)
33 return response

Callers

nothing calls this directly

Calls 4

HttpResponseClass · 0.90
get_view_nameFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected