diff --git a/activity_log/middleware.py b/activity_log/middleware.py index 65c351c..9195aba 100644 --- a/activity_log/middleware.py +++ b/activity_log/middleware.py @@ -36,8 +36,12 @@ def process_response(self, request, response): return response def _write_log(self, request, response, body): + user_exists_or_authenticated = ( + bool(getattr(request, 'user', None)) and + request.user.is_authenticated() + ) miss_log = [ - not(conf.ANONIMOUS or request.user.is_authenticated()), + not(conf.ANONIMOUS or user_exists_or_authenticated), request.method not in conf.METHODS, any(url in request.path for url in conf.EXCLUDE_URLS) ]