Skip to content

Add regex and iregex lookups to filters for string fields #19903

@miaow2

Description

@miaow2

NetBox version

v4.3.4

Feature type

Change to existing functionality

Proposed functionality

Now we have the following filter lookups for string fields in NetBox:

  • n
  • ic
  • nic
  • isw
  • nisw
  • iew
  • niew
  • ie
  • nie
  • empty

I want to add support for regex and iregex Django ORM lookups in filters for string fields.
It can be easily done by adding them to FILTER_CHAR_BASED_LOOKUP_MAP variable in netbox/utilities/constants.py.
I've tested this on my local NetBox deployment, and it's working well.

Use case

At my company, we have a specific naming convention, and in some cases, it's challenging to filter devices by name using existing lookups. Therefore, I propose this feature.

Also, regex and iregex are built-in Django ORM lookups, and PostgreSQL fully supports them.
Now, only GraphQL supports these lookups, adding regex lookups will make filtering in other interfaces more consistent.

If the feature is accepted, you can assign it to me, and I will make a PR with updates for code, tests, and docs.

Database changes

No database changes

External dependencies

No response

Metadata

Metadata

Assignees

Labels

complexity: lowRequires minimal effort to implementstatus: acceptedThis issue has been accepted for implementationtype: featureIntroduction of new functionality to the application

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions