Merge pull request #6 from vfigueiro/master

quick fix for AttributeError at admin urls
This commit is contained in:
Jan-Jelle Kester 2014-02-13 13:58:46 +01:00
commit 6c3ec169ee

View file

@ -32,7 +32,8 @@ class AuditlogMiddleware(object):
Disconnects the signal receiver to prevent it from staying active.
"""
# Disconnecting the signal receiver is required because it will not be garbage collected (non-weak reference)
pre_save.disconnect(sender=LogEntry, dispatch_uid=(self.__class__, request.auditlog_ts))
if hasattr(request, 'auditlog_ts'): # admin wipes auditlog_ts from request...
pre_save.disconnect(sender=LogEntry, dispatch_uid=(self.__class__, request.auditlog_ts))
return response
@ -40,7 +41,8 @@ class AuditlogMiddleware(object):
"""
Disconnects the signal receiver to prevent it from staying active in case of an exception.
"""
pre_save.disconnect(sender=LogEntry, dispatch_uid=(self.__class__, request.auditlog_ts))
if hasattr(request, 'auditlog_ts'):
pre_save.disconnect(sender=LogEntry, dispatch_uid=(self.__class__, request.auditlog_ts))
return None