diff --git a/netbox/extras/events.py b/netbox/extras/events.py index 6ac78e19f..836f825d1 100644 --- a/netbox/extras/events.py +++ b/netbox/extras/events.py @@ -53,9 +53,9 @@ def serialize_for_event(instance): def get_snapshots(instance, event_type): snapshots = { 'prechange': getattr(instance, '_prechange_snapshot', None), - 'postchange': None, + 'postchange': getattr(instance, '_postchange_snapshot', None), } - if event_type != OBJECT_DELETED: + if snapshots['postchange'] is None and event_type != OBJECT_DELETED: # Use model's serialize_object() method if defined; fall back to serialize_object() utility function if hasattr(instance, 'serialize_object'): snapshots['postchange'] = instance.serialize_object() diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index b6eb62884..f7b043f63 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -121,7 +121,8 @@ class ChangeLoggingMixin(DeleteMixin, models.Model): if hasattr(self, '_prechange_snapshot'): objectchange.prechange_data = self._prechange_snapshot if action in (ObjectChangeActionChoices.ACTION_CREATE, ObjectChangeActionChoices.ACTION_UPDATE): - objectchange.postchange_data = self.serialize_object(exclude=exclude) + self._postchange_snapshot = self.serialize_object(exclude=exclude) + objectchange.postchange_data = self._postchange_snapshot return objectchange