-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v3.4.2
Feature type
Data model extension
Proposed functionality
Currently, once you've created a tag, it can be assigned to any object of any type.
I propose that tags can be optionally linked to a set of object types, in the same way that custom fields are linked to object types. Then, when editing a particular object, you'd only be able to select and add tags bound to that object's type.
Tags which are not bound to any object type would be continue to be applicable to all object types.
Use case
There are a wide range of uses for tags: classifying devices, interfaces, IP addresses etc. However, many tags are only meaningful to specific object types.
Being able to restrict them in this way would:
- Reduce the size of drop-down menus for tag selection, making it quicker and easier for users to add tags
- Prevent unsuitable tags being added to objects, in a way which is much easier to maintain and more transparent than custom validators
Database changes
There would need to be a new many-to-many join between tag and content type, just like custom fields:
class CustomField(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
content_types = models.ManyToManyField(
to=ContentType,
related_name='custom_fields',
limit_choices_to=FeatureQuery('custom_fields'),
help_text=_('The object(s) to which this field applies.')
)
External dependencies
None