mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 17:59:11 -06:00
Fixes #4931: Fix DoesNotExist exception when deleting devices
This commit is contained in:
parent
cea6c98f54
commit
7b45d06631
@ -13,6 +13,7 @@
|
|||||||
* [#4914](https://github.com/netbox-community/netbox/issues/4914) - Fix toggling cable status under device view
|
* [#4914](https://github.com/netbox-community/netbox/issues/4914) - Fix toggling cable status under device view
|
||||||
* [#4921](https://github.com/netbox-community/netbox/issues/4921) - Render non-viewable devices as unavailable space in rack elevations
|
* [#4921](https://github.com/netbox-community/netbox/issues/4921) - Render non-viewable devices as unavailable space in rack elevations
|
||||||
* [#4930](https://github.com/netbox-community/netbox/issues/4930) - Replicate label values when instantiating device type components
|
* [#4930](https://github.com/netbox-community/netbox/issues/4930) - Replicate label values when instantiating device type components
|
||||||
|
* [#4931](https://github.com/netbox-community/netbox/issues/4931) - Fix DoesNotExist exception when deleting devices
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -71,11 +71,16 @@ class ComponentModel(models.Model):
|
|||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
# Annotate the parent Device
|
# Annotate the parent Device
|
||||||
|
try:
|
||||||
|
device = self.device
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# The parent Device has already been deleted
|
||||||
|
device = None
|
||||||
return ObjectChange(
|
return ObjectChange(
|
||||||
changed_object=self,
|
changed_object=self,
|
||||||
object_repr=str(self),
|
object_repr=str(self),
|
||||||
action=action,
|
action=action,
|
||||||
related_object=self.device,
|
related_object=device,
|
||||||
object_data=serialize_object(self)
|
object_data=serialize_object(self)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user