Remove static labels from filters in filtersets #8770

Closed
opened 2025-12-29 20:41:01 +01:00 by adam · 3 comments
Owner

Originally created by @jeremystretch on GitHub (Oct 24, 2023).

Proposed Changes

Remove the static label parameter passed to filters where they do not convey meaningful context. For example:

class SomeFilterSet(NetBoxModelFilterSet):
    site_id = django_filters.ModelMultipleChoiceFilter(
        queryset=Site.objects.all(),
        label=_('Site (ID)'),
    )
    site = django_filters.ModelMultipleChoiceFilter(
        field_name='site__slug',
        queryset=Site.objects.all(),
        to_field_name='slug',
        label=_('Site (slug)'),
    )

The Site (ID) and Site (slug) labels would be removed. Any filter labels which go beyond echoing the name of the filter itself to provide genuinely useful context can be retained.

As an alternative to dropping such labels outright, we could instead simplify them by omitting the ID or slug suffix, which would obviate the need for additional string translations.

Justification

Removing these extra labels greatly reduces the number of strings which must be translated, without significantly detracting from the API schema definitions. These labels add little value:

Screenshot 2023-10-24 at 16-15-27 NetBox REST API

Originally created by @jeremystretch on GitHub (Oct 24, 2023). ### Proposed Changes Remove the static `label` parameter passed to filters where they do not convey meaningful context. For example: ```python class SomeFilterSet(NetBoxModelFilterSet): site_id = django_filters.ModelMultipleChoiceFilter( queryset=Site.objects.all(), label=_('Site (ID)'), ) site = django_filters.ModelMultipleChoiceFilter( field_name='site__slug', queryset=Site.objects.all(), to_field_name='slug', label=_('Site (slug)'), ) ``` The `Site (ID)` and `Site (slug)` labels would be removed. Any filter labels which go beyond echoing the name of the filter itself to provide genuinely useful context can be retained. As an alternative to dropping such labels outright, we could instead simplify them by omitting the ID or slug suffix, which would obviate the need for additional string translations. ### Justification Removing these extra labels greatly reduces the number of strings which must be translated, without significantly detracting from the API schema definitions. These labels add little value: ![Screenshot 2023-10-24 at 16-15-27 NetBox REST API](https://github.com/netbox-community/netbox/assets/13487278/97b274a1-1ded-4e34-a8c5-5301cd1b9e60)
adam added the pending closurestatus: under reviewtype: housekeeping labels 2025-12-29 20:41:01 +01:00
adam closed this issue 2025-12-29 20:41:01 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 23, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jan 23, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeffgdotorg commented on GitHub (Jan 24, 2024):

@jeremystretch do we want to let this one get auto-closed just as we're starting to get uptake on some new translations?

@jeffgdotorg commented on GitHub (Jan 24, 2024): @jeremystretch do we want to let this one get auto-closed just as we're starting to get uptake on some new translations?
Author
Owner

@jeremystretch commented on GitHub (Jan 24, 2024):

I'll close it out for now. We might revisit the idea during future work on filters.

@jeremystretch commented on GitHub (Jan 24, 2024): I'll close it out for now. We might revisit the idea during future work on filters.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8770