Document that lookup expressions don't work on custom fields #5792

Closed
opened 2025-12-29 19:32:44 +01:00 by adam · 4 comments
Owner

Originally created by @sol1james on GitHub (Dec 17, 2021).

Change Type

Addition

Area

REST API

Proposed Changes

I tried using a lookup expression on a custom field and it didn't work. Ie I used this URL:
https://netbox.xxxx.cloud/dcim/devices/?q=&cf_import_group__n=rumble_nov_2021
it returned all devices including those where import_group=rumble_nov_2021

I googled it and found this post which indicates that you can't do what I was trying to do:
https://groups.google.com/g/netbox-discuss/c/_6_zdVrKo8U

The documentation (https://netbox.readthedocs.io/en/stable/rest-api/filtering/) is a bit ambiguous about this so I want to clarify it.

I created a suggested change and started making a pull request when I saw that I needed to create an issue first. So I'm creating this issue then I will complete the pull request.

Originally created by @sol1james on GitHub (Dec 17, 2021). ### Change Type Addition ### Area REST API ### Proposed Changes I tried using a lookup expression on a custom field and it didn't work. Ie I used this URL: https://netbox.xxxx.cloud/dcim/devices/?q=&cf_import_group__n=rumble_nov_2021 it returned all devices including those where import_group=rumble_nov_2021 I googled it and found this post which indicates that you can't do what I was trying to do: https://groups.google.com/g/netbox-discuss/c/_6_zdVrKo8U The documentation (https://netbox.readthedocs.io/en/stable/rest-api/filtering/) is a bit ambiguous about this so I want to clarify it. I created a suggested change and started making a pull request when I saw that I needed to create an issue first. So I'm creating this issue then I will complete the pull request.
adam added the type: documentation label 2025-12-29 19:32:44 +01:00
adam closed this issue 2025-12-29 19:32:44 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 18, 2021):

This was implemented in v3.1 (see #6615).

@jeremystretch commented on GitHub (Dec 18, 2021): This was implemented in v3.1 (see #6615).
Author
Owner

@sol1james commented on GitHub (Dec 20, 2021):

I've tested this in 3.1 and it didn't work for me. This is the URL I tried:
http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__ic=1600&cf_droids_url=

The query returned all tenants.

I'm a bit surprised we seem to have such a recent version of netbox but http://netbox.hq.sol1.net/api/status/ says "netbox-version": "3.1.0".

@sol1james commented on GitHub (Dec 20, 2021): I've tested this in 3.1 and it didn't work for me. This is the URL I tried: http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__ic=1600&cf_droids_url= The query returned all tenants. I'm a bit surprised we seem to have such a recent version of netbox but http://netbox.hq.sol1.net/api/status/ says "netbox-version": "3.1.0".
Author
Owner

@jeremystretch commented on GitHub (Dec 20, 2021):

If you believe it's not working as intended, please open a detailed bug report. However, you seem to be applying a string filter to a numeric field, which is not supported.

@jeremystretch commented on GitHub (Dec 20, 2021): If you believe it's not working as intended, please open a detailed [bug report](https://github.com/netbox-community/netbox/issues/new?assignees=&labels=type%3A+bug&template=bug_report.yaml). However, you seem to be applying a string filter to a numeric field, which is not supported.
Author
Owner

@sol1james commented on GitHub (Dec 21, 2021):

Yes, that was a user error

However I tried the numeric field expressions and they didn't work as expected either, so created issue #8125

@sol1james commented on GitHub (Dec 21, 2021): Yes, that was a user error However I tried the numeric field expressions and they didn't work as expected either, so created issue #8125
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5792