Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion netbox_custom_objects/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions netbox_custom_objects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down