Skip to content

Commit 07f4c15

Browse files
committed
Improve param handling on get_through_model
1 parent 48ca563 commit 07f4c15

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

netbox_custom_objects/field_types.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def get_joining_columns(self, reverse_join=False):
672672

673673

674674
class MultiObjectFieldType(FieldType):
675-
def get_through_model(self, field, model):
675+
def get_through_model(self, field, model_string):
676676
"""
677677
Creates a through model with deferred model references
678678
"""
@@ -701,21 +701,18 @@ def get_through_model(self, field, model):
701701
and field.custom_object_type.id == custom_object_type_id
702702
)
703703

704-
# Use the actual model if provided, otherwise use string reference
705-
source_model = model
706-
707704
attrs = {
708705
"__module__": "netbox_custom_objects.models",
709706
"Meta": meta,
710707
"id": models.AutoField(primary_key=True),
711708
"source": models.ForeignKey(
712-
source_model,
709+
model_string,
713710
on_delete=models.CASCADE,
714711
related_name="+",
715712
db_column="source_id",
716713
),
717714
"target": models.ForeignKey(
718-
"self" if is_self_referential else model,
715+
"self" if is_self_referential else model_string,
719716
on_delete=models.CASCADE,
720717
related_name="+",
721718
db_column="target_id",

0 commit comments

Comments
 (0)