So I have created a Django-app with a login form and using login(request, user) in my view.py
to login the user. This is the main page and has the location mypage.com
. I also created another function in my view.py
called log_out
:
def log_out(request):
logout(request)
return redirect('/')
This function is used to log out a user using the url: mysite.com/logout
as defined in my url.py
:
url(r'^logout/', views.log_out, name='log_out'),
This is working to log out the user, however the user is being logged out as I'm typing in the logout-url into the address-field of my browser, and before hitting enter to go to that endpoint.
I would like it to not log out the user when typing in the url, and wait until I'm "entering" the site.
Can anyone help me with this one?