Skip to main content

csrf

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

def csrf(
request: HttpRequest
) - > dict

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

Parameters

NameTypeDescription
requestHttpRequestThe current HTTP request object used to retrieve the CSRF token from the middleware or view context.

Returns

TypeDescription
dictA dictionary containing a 'csrf_token' key mapped to a lazy object that resolves to the CSRF token string or a 'NOTPROVIDED' sentinel value.