Skip to main content

logout_then_login

Log out the user if they are logged in. Then redirect to the login page.

def logout_then_login(
request: HttpRequest,
login_url: string = None
) - > HttpResponse

Log out the user if they are logged in. Then redirect to the login page.

Parameters

NameTypeDescription
requestHttpRequestThe current HTTP request object representing the user session to be terminated.
login_urlstring = NoneThe URL or named URL pattern to redirect the user to after logout; defaults to the LOGIN_URL setting if not provided.

Returns

TypeDescription
HttpResponseA redirect response that sends the user to the specified login URL after terminating their session.