diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py index 9dfe651fe6..bdd8257b2e 100644 --- a/django/contrib/admin/views/decorators.py +++ b/django/contrib/admin/views/decorators.py @@ -90,8 +90,6 @@ def staff_member_required(view_func): if user.is_active and user.is_staff: login(request, user) # TODO: set last_login with an event. - user.last_login = datetime.datetime.now() - user.save() if request.POST.has_key('post_data'): post_data = _decode_post_data(request.POST['post_data']) if post_data and not post_data.has_key(LOGIN_FORM_KEY): diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index 8c92732f44..d37450805f 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -1,3 +1,4 @@ +import datetime from django.core.exceptions import ImproperlyConfigured SESSION_KEY = '_auth_user_id' @@ -48,6 +49,8 @@ def login(request, user): if user is None: user = request.user # TODO: It would be nice to support different login methods, like signed cookies. + user.last_login = datetime.datetime.now() + user.save() request.session[SESSION_KEY] = user.id request.session[BACKEND_SESSION_KEY] = user.backend