Skip to content

Commit 9a26cdc

Browse files
committed
Filter object fields to only check one related_object_type per COT in _has_circular_reference
1 parent ff32497 commit 9a26cdc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

netbox_custom_objects/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ def _has_circular_reference(self, custom_object_type, visited):
10711071
visited.add(custom_object_type.id)
10721072

10731073
# Check all object and multiobject fields in this custom object type
1074+
related_objects_checked = set()
10741075
for field in custom_object_type.fields.filter(
10751076
type__in=[
10761077
CustomFieldTypeChoices.TYPE_OBJECT,
@@ -1079,6 +1080,9 @@ def _has_circular_reference(self, custom_object_type, visited):
10791080
related_object_type__isnull=False,
10801081
related_object_type__app_label=APP_LABEL
10811082
):
1083+
if field.related_object_type in related_objects_checked:
1084+
continue
1085+
related_objects_checked.add(field.related_object_type)
10821086

10831087
# Get the related custom object type directly from the object_type relationship
10841088
try:

0 commit comments

Comments
 (0)