@receiver(user_logged_out)
def log_user_lockout(sender, request, user, signal, *args, **kwargs):
 if (not user):
  return
 try:
  username = user.get_username()
 except AttributeError:
  username = user.username
 access_logs = AccessLog.objects.filter(username=username, logout_time__isnull=True).order_by('-attempt_time')
 if access_logs:
  access_log = access_logs[0]
  access_log.logout_time = now()
  access_log.save()

@ receiver ( user_logged_out ) def log_user_lockout ( sender , request , user , signal , * args , ** kwargs ) : if ( not user ) : return try : username = user . get_username ( ) except AttributeError : username = user . username access_logs = AccessLog . objects . filter ( username = username , logout_time__isnull = True ) . order_by ( '-attempt_time' ) if access_logs : access_log = access_logs [ 0 ] access_log . logout_time = now ( ) access_log . save ( )
when a user logs out .