Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #2368 -- Fixed KeyError when trying to log out more than once. …

…Thanks, Gary Wilson

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c19ef69c5c9435bd3c559f32e34d56ae76c645ac 1 parent c4679bb
@adrianholovaty adrianholovaty authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 django/contrib/auth/__init__.py
View
10 django/contrib/auth/__init__.py
@@ -56,8 +56,14 @@ def logout(request):
"""
Remove the authenticated user's ID from the request.
"""
- del request.session[SESSION_KEY]
- del request.session[BACKEND_SESSION_KEY]
+ try:
+ del request.session[SESSION_KEY]
+ except KeyError:
+ pass
+ try:
+ del request.session[BACKEND_SESSION_KEY]
+ except KeyError:
+ pass
def get_user(request):
from django.contrib.auth.models import AnonymousUser
Please sign in to comment.
Something went wrong with that request. Please try again.