Here is the problem I am facing with the Django Authenetication
Basically, this should work:
from django.contrib.auth import logout
def logout_view(request):
logout(request)
# Redirect to a success page.
Could you clarify by posting your view if it's not something like this?
Change session expire on close to False, with true it will not log you out until you close the browser
This worked for me. I was too stuck with this problem. Found the following solution on youtube.
My solution is a little modified though.
in views.py
from django.contrib.auth import authenticate, login, logout
from django.shortcuts import redirect
def auth_logout(request):
logout(request)
return redirect('home')
in urls.py
url(r'^logout$', views.auth_logout, name='auth_logout'),
views
from django.contrib.auth import logout
def logout_user(request):
"""
logout the user
"""
logout(request)
return HttpResponseRedirect('/qioness/connect/')
urls:
url(r'^userlogout/$',logout_user),
worked 4 me
In Django 1.4.* I've had problems with the logout()
function. It simply wasn't logging out my users.
Now I'm just using the contributed view to logout users and it works perfectly. Simply add this to your root urls.py
file if you don't want to do anything else special:
(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/login'}),
and you'll be good to go.
Happy Djangoing.