Changes between Version 12 and Version 13 of AuditTrail
- Timestamp:
- Aug 9, 2008, 1:25:22 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AuditTrail
v12 v13 1 1 = Automating an audit trail = 2 2 3 As raised in [http://groups.google.com/group/django-developers/browse_thread/thread/ab7649e4abd4e589 a recent discussion on django-developers], this code is one solution for creating an audit trail for a given model. '''This is working in multiple production sites, but is still incomplete. See [#Caveats Caveats] below for more information.''' The code below requires an SVN checkout as of r 7790or later.3 As raised in [http://groups.google.com/group/django-developers/browse_thread/thread/ab7649e4abd4e589 a recent discussion on django-developers], this code is one solution for creating an audit trail for a given model. '''This is working in multiple production sites, but is still incomplete. See [#Caveats Caveats] below for more information.''' The code below requires an SVN checkout as of r8223 or later. 4 4 5 5 == Usage == … … 187 187 kwargs[field_arr[0]] = _audit_track(instance, field_arr) 188 188 model._default_manager.create(**kwargs) 189 dispatcher.connect(_audit, signal=models.signals.post_save, sender=cls, weak=False) 189 ## Uncomment this line for pre r8223 Django builds 190 #dispatcher.connect(_audit, signal=models.signals.post_save, sender=cls, weak=False) 191 ## Comment this line for pre r8223 Django builds 192 models.signals.post_save.connect(_audit, sender=cls, weak=False) 190 193 191 194 if self.opts['audit_deletes']: … … 200 203 kwargs[field_arr[0]] = _audit_track(instance, field_arr) 201 204 model._default_manager.create(**kwargs) 202 dispatcher.connect(_audit_delete, signal=models.signals.pre_delete, sender=cls, weak=False) 203 204 dispatcher.connect(_contribute, signal=models.signals.class_prepared, sender=cls, weak=False) 205 ## Uncomment this line for pre r8223 Django builds 206 #dispatcher.connect(_audit_delete, signal=models.signals.pre_delete, sender=cls, weak=False) 207 ## Comment this line for pre r8223 Django builds 208 models.signals.pre_delete.connect(_audit_delete, sender=cls, weak=False) 209 210 ## Uncomment this line for pre r8223 Django builds 211 #dispatcher.connect(_contribute, signal=models.signals.class_prepared, sender=cls, weak=False) 212 ## Comment this line for pre r8223 Django builds 213 models.signals.class_prepared.connect(_contribute, sender=cls, weak=False) 205 214 206 215 class AuditTrailDescriptor(object):