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:
@ -6,6 +6,7 @@
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* [#3900](https://github.com/netbox-community/netbox/issues/3900) - Fix exception when deleting device types
|
||||
* [#3914](https://github.com/netbox-community/netbox/issues/3914) - Fix interface filter field when unauthenticated
|
||||
|
||||
---
|
||||
|
@ -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)
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user