diff --git a/netbox_custom_objects/api/serializers.py b/netbox_custom_objects/api/serializers.py index c13ce5b..69aa67f 100644 --- a/netbox_custom_objects/api/serializers.py +++ b/netbox_custom_objects/api/serializers.py @@ -211,7 +211,16 @@ def get_serializer_class(model, skip_object_fields=False): # Create field list including all necessary fields base_fields = ["id", "url", "display", "created", "last_updated", "tags"] - custom_field_names = [field.name for field in model_fields] + + # Only include custom field names that will actually be added to the serializer + custom_field_names = [] + for field in model_fields: + if skip_object_fields and field.type in [ + CustomFieldTypeChoices.TYPE_OBJECT, CustomFieldTypeChoices.TYPE_MULTIOBJECT + ]: + continue + custom_field_names.append(field.name) + all_fields = base_fields + custom_field_names meta = type( diff --git a/netbox_custom_objects/views.py b/netbox_custom_objects/views.py index 1532923..3ac9e82 100644 --- a/netbox_custom_objects/views.py +++ b/netbox_custom_objects/views.py @@ -629,6 +629,9 @@ def get_form(self, queryset): attrs, ) + # Set the model attribute that NetBox form mixins expect + form.model = queryset.model + return form