diff --git a/docs/release-notes/version-3.2.md b/docs/release-notes/version-3.2.md index e3332d706..2b85e6eda 100644 --- a/docs/release-notes/version-3.2.md +++ b/docs/release-notes/version-3.2.md @@ -152,6 +152,7 @@ Where it is desired to limit the range of available VLANs within a group, users * [#8869](https://github.com/netbox-community/netbox/issues/8869) - Fix NoReverseMatch exception when displaying tag w/assignments * [#8872](https://github.com/netbox-community/netbox/issues/8872) - Enable filtering by custom object fields * [#8970](https://github.com/netbox-community/netbox/issues/8970) - Permit nested inventory item templates on device types +* [#8976](https://github.com/netbox-community/netbox/issues/8976) - Add missing `object_type` field on CustomField REST API serializer ### Other Changes diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index 36b307b39..f4cf6f66a 100644 --- a/netbox/extras/api/serializers.py +++ b/netbox/extras/api/serializers.py @@ -78,15 +78,18 @@ class CustomFieldSerializer(ValidatedModelSerializer): many=True ) type = ChoiceField(choices=CustomFieldTypeChoices) + object_type = ContentTypeField( + queryset=ContentType.objects.all() + ) filter_logic = ChoiceField(choices=CustomFieldFilterLogicChoices, required=False) data_type = serializers.SerializerMethodField() class Meta: model = CustomField fields = [ - 'id', 'url', 'display', 'content_types', 'type', 'data_type', 'name', 'label', 'description', 'required', - 'filter_logic', 'default', 'weight', 'validation_minimum', 'validation_maximum', 'validation_regex', - 'choices', 'created', 'last_updated', + 'id', 'url', 'display', 'content_types', 'type', 'object_type', 'data_type', 'name', 'label', 'description', + 'required', 'filter_logic', 'default', 'weight', 'validation_minimum', 'validation_maximum', + 'validation_regex', 'choices', 'created', 'last_updated', ] def get_data_type(self, obj): diff --git a/netbox/extras/forms/models.py b/netbox/extras/forms/models.py index 071f80453..78b627662 100644 --- a/netbox/extras/forms/models.py +++ b/netbox/extras/forms/models.py @@ -48,6 +48,10 @@ class CustomFieldForm(BootstrapMixin, forms.ModelForm): class Meta: model = CustomField fields = '__all__' + help_texts = { + 'type': "The type of data stored in this field. For object/multi-object fields, select the related object " + "type below." + } widgets = { 'type': StaticSelect(), 'filter_logic': StaticSelect(),