Skip to content

Commit 6e17b96

Browse files
authored
Merge pull request #217 from netboxlabs/104-bulk-edit
104 bulk edit
2 parents 24a17b0 + 9a841a5 commit 6e17b96

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

netbox_custom_objects/api/serializers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,16 @@ def get_serializer_class(model, skip_object_fields=False):
211211

212212
# Create field list including all necessary fields
213213
base_fields = ["id", "url", "display", "created", "last_updated", "tags"]
214-
custom_field_names = [field.name for field in model_fields]
214+
215+
# Only include custom field names that will actually be added to the serializer
216+
custom_field_names = []
217+
for field in model_fields:
218+
if skip_object_fields and field.type in [
219+
CustomFieldTypeChoices.TYPE_OBJECT, CustomFieldTypeChoices.TYPE_MULTIOBJECT
220+
]:
221+
continue
222+
custom_field_names.append(field.name)
223+
215224
all_fields = base_fields + custom_field_names
216225

217226
meta = type(

netbox_custom_objects/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ def get_form(self, queryset):
629629
attrs,
630630
)
631631

632+
# Set the model attribute that NetBox form mixins expect
633+
form.model = queryset.model
634+
632635
return form
633636

634637

0 commit comments

Comments
 (0)