MCPcopy
hub / github.com/django/django / csrf

Function csrf

django/template/context_processors.py:19–35  ·  view source on GitHub ↗

Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if it has not been provided by either a view decorator or the middleware

(request)

Source from the content-addressed store, hash-verified

17
18
19def csrf(request):
20 """
21 Context processor that provides a CSRF token, or the string 'NOTPROVIDED'
22 if it has not been provided by either a view decorator or the middleware
23 """
24
25 def _get_val():
26 token = get_token(request)
27 if token is None:
28 # In order to be able to provide debugging info in the
29 # case of misconfiguration, we use a sentinel value
30 # instead of returning an empty dict.
31 return "NOTPROVIDED"
32 else:
33 return token
34
35 return {"csrf_token": SimpleLazyObject(_get_val)}
36
37
38def debug(request):

Callers 2

csrf_viewFunction · 0.90

Calls 1

SimpleLazyObjectClass · 0.90

Tested by 2

csrf_viewFunction · 0.72