summaryrefslogtreecommitdiff
path: root/django/contrib/auth/views.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-01 17:02:32 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-01 17:02:32 +0000
commit3e6f4674e2fc190c2116d77066d18f42bd3bcbae (patch)
tree8ff55dd5ba08b69c32f88ea6d647c0214d47f7b1 /django/contrib/auth/views.py
parent35a1f22bc2f7d9fcf836a7295433c6565f5949ec (diff)
Fixed #10460: the logout view can now redirect like the rest of the auth views. Thanks, chronos and steingrd.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10332 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/auth/views.py')
-rw-r--r--django/contrib/auth/views.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 18572f1584..f753ed6de8 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -43,12 +43,18 @@ def login(request, template_name='registration/login.html', redirect_field_name=
}, context_instance=RequestContext(request))
login = never_cache(login)
-def logout(request, next_page=None, template_name='registration/logged_out.html'):
+def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME):
"Logs out the user and displays 'You are logged out' message."
from django.contrib.auth import logout
logout(request)
if next_page is None:
- return render_to_response(template_name, {'title': _('Logged out')}, context_instance=RequestContext(request))
+ redirect_to = request.REQUEST.get(redirect_field_name, '')
+ if redirect_to:
+ return HttpResponseRedirect(redirect_to)
+ else:
+ return render_to_response(template_name, {
+ 'title': _('Logged out')
+ }, context_instance=RequestContext(request))
else:
# Redirect to this page until the session has been cleared.
return HttpResponseRedirect(next_page or request.path)