1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #2816: Handle exception when deleting a device with connected components

This commit is contained in:
Jeremy Stretch
2019-01-29 14:27:47 -05:00
parent 0256448dd8
commit 8bd9b258a8
2 changed files with 6 additions and 1 deletions

View File

@@ -54,7 +54,11 @@ class ComponentModel(models.Model):
"""
Log an ObjectChange including the parent Device/VM.
"""
parent = self.device if self.device is not None else getattr(self, 'virtual_machine', None)
try:
parent = getattr(self, 'device', None) or getattr(self, 'virtual_machine', None)
except ObjectDoesNotExist:
# The parent device/VM has already been deleted
parent = None
ObjectChange(
user=user,
request_id=request_id,