mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #4301: Fix exception when deleting device type with components
This commit is contained in:
@ -13,6 +13,7 @@
|
|||||||
* [#4282](https://github.com/netbox-community/netbox/issues/4282) - Fix label on export button for device types
|
* [#4282](https://github.com/netbox-community/netbox/issues/4282) - Fix label on export button for device types
|
||||||
* [#4285](https://github.com/netbox-community/netbox/issues/4285) - Include A/Z termination sites in provider circuits table
|
* [#4285](https://github.com/netbox-community/netbox/issues/4285) - Include A/Z termination sites in provider circuits table
|
||||||
* [#4295](https://github.com/netbox-community/netbox/issues/4295) - Fix assignment of parent LAG during interface bulk edit
|
* [#4295](https://github.com/netbox-community/netbox/issues/4295) - Fix assignment of parent LAG during interface bulk edit
|
||||||
|
* [#4301](https://github.com/netbox-community/netbox/issues/4301) - Fix exception when deleting device type with components
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
@ -37,11 +37,17 @@ class ComponentTemplateModel(models.Model):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def to_objectchange(self, action):
|
def to_objectchange(self, action):
|
||||||
|
# Annotate the parent DeviceType
|
||||||
|
try:
|
||||||
|
device_type = self.device_type
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# The parent DeviceType has already been deleted
|
||||||
|
device_type = 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_type,
|
related_object=device_type,
|
||||||
object_data=serialize_object(self)
|
object_data=serialize_object(self)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user