diff --git a/CHANGELOG.md b/CHANGELOG.md index 33cf21571..c4b5df057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ v2.4.4 (FUTURE) ## Bug Fixes +* [#2353](https://github.com/digitalocean/netbox/issues/2353) - Handle `DoesNotExist` exception when deleting a device with connected interfaces * [#2354](https://github.com/digitalocean/netbox/issues/2354) - Increased maximum MTU for interfaces to 65536 bytes * [#2355](https://github.com/digitalocean/netbox/issues/2355) - Added item count to inventory tab on device view * [#2368](https://github.com/digitalocean/netbox/issues/2368) - Record change in device changelog when altering cluster assignment diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index cedad8bed..19c75bdb9 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -2072,6 +2072,7 @@ class InterfaceConnection(models.Model): (self.interface_a, self.interface_b), (self.interface_b, self.interface_a), ) + for interface, peer_interface in interfaces: if action == OBJECTCHANGE_ACTION_DELETE: connection_data = { @@ -2082,11 +2083,17 @@ class InterfaceConnection(models.Model): 'connected_interface': peer_interface.pk, 'connection_status': self.connection_status } + + try: + parent_obj = interface.parent + except ObjectDoesNotExist: + parent_obj = None + ObjectChange( user=user, request_id=request_id, changed_object=interface, - related_object=interface.parent, + related_object=parent_obj, action=OBJECTCHANGE_ACTION_UPDATE, object_data=serialize_object(interface, extra=connection_data) ).save()