Răsfoiți Sursa

Fixes #3227: Fix exception when deleting a circuit with a termination(s)

Jeremy Stretch 6 ani în urmă
părinte
comite
b9b009c0b5
2 a modificat fișierele cu 7 adăugiri și 1 ștergeri
  1. 1 0
      CHANGELOG.md
  2. 6 1
      netbox/circuits/models.py

+ 1 - 0
CHANGELOG.md

@@ -20,6 +20,7 @@
 * [#3190](https://github.com/digitalocean/netbox/issues/3190) - Fix custom field rendering for Jinja2 export templates
 * [#3190](https://github.com/digitalocean/netbox/issues/3190) - Fix custom field rendering for Jinja2 export templates
 * [#3211](https://github.com/digitalocean/netbox/issues/3211) - Fix error handling when attempting to delete a protected object via API
 * [#3211](https://github.com/digitalocean/netbox/issues/3211) - Fix error handling when attempting to delete a protected object via API
 * [#3223](https://github.com/digitalocean/netbox/issues/3223) - Fix filtering devices by "has power outlets"
 * [#3223](https://github.com/digitalocean/netbox/issues/3223) - Fix filtering devices by "has power outlets"
+* [#3227](https://github.com/digitalocean/netbox/issues/3227) - Fix exception when deleting a circuit with a termination(s)
 
 
 ---
 ---
 
 

+ 6 - 1
netbox/circuits/models.py

@@ -274,11 +274,16 @@ class CircuitTermination(CableTermination):
         """
         """
         Reference the parent circuit when recording the change.
         Reference the parent circuit when recording the change.
         """
         """
+        try:
+            related_object = self.circuit
+        except Circuit.DoesNotExist:
+            # Parent circuit has been deleted
+            related_object = None
         ObjectChange(
         ObjectChange(
             user=user,
             user=user,
             request_id=request_id,
             request_id=request_id,
             changed_object=self,
             changed_object=self,
-            related_object=self.circuit,
+            related_object=related_object,
             action=action,
             action=action,
             object_data=serialize_object(self)
             object_data=serialize_object(self)
         ).save()
         ).save()