Skip to content

Commit 1a57081

Browse files
committed
Filter object fields to only check one related_object_type per COT in _has_circular_reference
1 parent 1071d2c commit 1a57081

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

netbox_custom_objects/api/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Meta:
5757
"related_object_type",
5858
"app_label",
5959
"model",
60+
"group_name",
6061
)
6162

6263
def validate(self, attrs):

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)