Skip to content

Support filter lookups for custom fields #6615

@jeremystretch

Description

@jeremystretch

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

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions