Changes between Version 9 and Version 10 of AuditTrail
- Timestamp:
- Oct 1, 2007, 1:02:33 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AuditTrail
v9 v10 56 56 As you can see, the audit trail is listed with the most recent state first. Each entry also inclues a timestamp when the edit took place. 57 57 58 Saves and deletes are both tracked, and can be filtered on via {{{ Person.history.filter(_audit_change_type='_') }}}. Do not use underscore, use ' U' for inserts/updates, and 'D' for deletes. If #4879 lands, then we will be able to distinguish between inserts and updates, and at that point the audit trail will use 'I' for inserts and 'U' for updates.58 Saves and deletes are both tracked, and can be filtered on via {{{ Person.history.filter(_audit_change_type='_') }}}. Do not use underscore, use 'I' for inserts, 'U' for updates, and 'D' for deletes. 59 59 60 60 ForeignKeys and OneToOneFields are now supported both for saving and accessing the audit data. However, it does not archive the contents of the ForeignKey table for the appropriate entries at the same time, and will fail if the ForeignKey a given audit entry is related to is deleted (including if you're auditing the ForeignKey table as well, it does not have a way to link the two audit tables together). … … 172 172 return field_arr[2] 173 173 174 def _audit(sender, instance ):174 def _audit(sender, instance, created): 175 175 # Write model changes to the audit model. 176 176 # instance is the current (non-audit) model. … … 180 180 kwargs[field.name] = getattr(instance, field.name) 181 181 if self.opts['save_change_type']: 182 kwargs['_audit_change_type'] = 'U' 182 if created: 183 kwargs['_audit_change_type'] = 'I' 184 else: 185 kwargs['_audit_change_type'] = 'U' 183 186 for field_arr in model._audit_track: 184 187 kwargs[field_arr[0]] = _audit_track(instance, field_arr) … … 247 250 'Meta': Meta, 248 251 '_audit_id': models.AutoField(primary_key=True), 249 '_audit_timestamp': models.DateTimeField(auto_now_add=True ),252 '_audit_timestamp': models.DateTimeField(auto_now_add=True, db_index=True), 250 253 '_audit__str__': cls.__str__.im_func, 251 254 '__str__': lambda self: '%s as of %s' % (self._audit__str__(), self._audit_timestamp), … … 254 257 255 258 if 'save_change_type' in kwargs and kwargs['save_change_type']: 256 attrs['_audit_change_type'] = models.CharField(max length=1)259 attrs['_audit_change_type'] = models.CharField(max_length=1) 257 260 258 261 if 'show_in_admin' in kwargs and kwargs['show_in_admin']: … … 272 275 else: 273 276 attrs[field.name] = copy.copy(field) 277 # If 'unique' is in there, we need to remove it, otherwise the index 278 # is created and multiple audit entries for one item fail. 279 attrs[field.name].unique = False 274 280 275 281 for track_field in _track_fields(kwargs['track_fields']):