LogoutView
Log out the user and display the 'You are logged out' message.
Attributes
| Attribute | Type | Description |
|---|---|---|
| http_method_names | list = ["post", "options"] | List of allowed HTTP methods for the view, restricted to POST and OPTIONS to ensure logout actions are not triggered by GET requests. |
| template_name | string = "registration/logged_out.html" | The path to the template used to render the 'logged out' confirmation page. |
| extra_context | dict = null | A dictionary of additional context variables to be passed to the template engine during rendering. |
Methods
post()
@classmethod
def post(
request: [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest),
args: list,
kwargs: dict
) - > [HttpResponseRedirect](../../../http/response/httpresponseredirect.md?sid=django_http_response_httpresponseredirect)
Logout may be done via POST.
Parameters
| Name | Type | Description |
|---|---|---|
| request | [HttpRequest](../../../http/request/httprequest.md?sid=django_http_request_httprequest) | The current HTTP request object containing the user session to be terminated. |
| args | list | Positional arguments passed to the view handler. |
| kwargs | dict | Keyword arguments passed to the view handler. |
Returns
| Type | Description |
|---|---|
[HttpResponseRedirect](../../../http/response/httpresponseredirect.md?sid=django_http_response_httpresponseredirect) | A redirect response to the success URL after the session is cleared, or the rendered template if the redirect target is the current path. |
get_default_redirect_url()
@classmethod
def get_default_redirect_url() - > str
Return the default redirect URL.
Returns
| Type | Description |
|---|---|
str | The resolved URL path where the user should be sent after logging out, prioritized by the next_page attribute, settings, or the current request path. |
get_context_data()
@classmethod
def get_context_data(
kwargs: dict
) - > dict
Constructs the template context dictionary, including site information and localized titles for the logout page.
Parameters
| Name | Type | Description |
|---|---|---|
| kwargs | dict | Additional keyword arguments to be merged into the template context. |
Returns
| Type | Description |
|---|---|
dict | A dictionary containing site, site_name, title, and any additional extra_context provided to the view. |