get_token
Return the CSRF token required for a POST form. The token is an alphanumeric value. A new token is created if one is not already set. A side effect of calling this function is to make the csrf_protect decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie' header to the outgoing response. For this reason, you may need to use this function lazily, as is done by the csrf context processor.
def get_token(
request: HttpRequest
) - > string
Return the CSRF token required for a POST form. The token is an alphanumeric value. A new token is created if one is not already set. A side effect of calling this function is to make the csrf_protect decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie' header to the outgoing response. For this reason, you may need to use this function lazily, as is done by the csrf context processor.
Parameters
| Name | Type | Description |
|---|---|---|
| request | HttpRequest | The current HTTP request object used to retrieve or initialize the CSRF cookie secret. |
Returns
| Type | Description |
|---|---|
string | An alphanumeric masked CSRF token used to validate state-changing requests. |