mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-03-16 22:20:26 +00:00
Make the set_actor method from the middleware static. Also, catch only the relevant exception.
This commit is contained in:
parent
839396d825
commit
3e3282392d
1 changed files with 3 additions and 2 deletions
|
|
@ -33,7 +33,8 @@ class AuditlogMiddleware(object):
|
|||
|
||||
return response
|
||||
|
||||
def set_actor(self, user, sender, instance, **kwargs):
|
||||
@staticmethod
|
||||
def set_actor(user, sender, instance, **kwargs):
|
||||
"""
|
||||
Signal receiver with an extra, required 'user' kwarg. This method becomes a real (valid) signal receiver when
|
||||
it is curried with the actor.
|
||||
|
|
@ -41,7 +42,7 @@ class AuditlogMiddleware(object):
|
|||
try:
|
||||
app_label, model_name = settings.AUTH_USER_MODEL.split('.')
|
||||
auth_user_model = get_model(app_label, model_name)
|
||||
except:
|
||||
except ValueError:
|
||||
auth_user_model = get_model('auth', 'user')
|
||||
if sender == LogEntry and isinstance(user, auth_user_model) and instance.actor is None:
|
||||
instance.actor = user
|
||||
|
|
|
|||
Loading…
Reference in a new issue