Support filter lookups for custom fields #5006

Closed
opened 2025-12-29 19:23:06 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Jun 16, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.6

Feature type

Change to existing functionality

Proposed functionality

Extend NetBox's filtering functionality to automatically generate lookup filters for a model's custom fields. For example, a custom field named foo applied to the dcim.Site model will result in a filter named cf_foo on SiteFilterSet. This filter will support either an exact match or an icontains lookup, depending on how the CustomField is configured. However, it will not support any further lookup logic, such as greater/less than evaluation for integers.

Implementing this feature would comprise automatically generating appropriate lookups for a custom field depending on its type. For example, integer fields should get __lt, __lte, __gt, __gte, and similar lookups. This might be done by extending either BaseFilterSet or the CustomFieldFilter class,

Use case

This extension of the existing filtering logic would enable users to filter on custom fields with the same degree of flexibility afforded to built-in model fields.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Jun 16, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.6 ### Feature type Change to existing functionality ### Proposed functionality Extend NetBox's [filtering functionality](https://netbox.readthedocs.io/en/stable/rest-api/filtering/) to automatically generate lookup filters for a model's custom fields. For example, a custom field named `foo` applied to the dcim.Site model will result in a filter named `cf_foo` on SiteFilterSet. This filter will support either an exact match or an `icontains` lookup, depending on how the CustomField is configured. However, it will not support any further lookup logic, such as greater/less than evaluation for integers. Implementing this feature would comprise automatically generating appropriate lookups for a custom field depending on its type. For example, integer fields should get `__lt`, `__lte`, `__gt`, `__gte`, and similar lookups. This might be done by extending either BaseFilterSet or the CustomFieldFilter class, ### Use case This extension of the existing filtering logic would enable users to filter on custom fields with the same degree of flexibility afforded to built-in model fields. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:23:06 +01:00
adam closed this issue 2025-12-29 19:23:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5006