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

Fixes #3900: Fix exception when deleting device types

This commit is contained in:
Jeremy Stretch
2020-01-15 10:23:07 -05:00
parent 685cf50268
commit 1ea820a50e
2 changed files with 9 additions and 1 deletions

View File

@@ -38,11 +38,18 @@ class ComponentTemplateModel(models.Model):
raise NotImplementedError()
def to_objectchange(self, action):
# Annotate the parent DeviceType
try:
parent = getattr(self, 'device_type', None)
except ObjectDoesNotExist:
# The parent DeviceType has already been deleted
parent = None
return ObjectChange(
changed_object=self,
object_repr=str(self),
action=action,
related_object=self.device_type,
related_object=parent,
object_data=serialize_object(self)
)