Custom field filtering not working #2965

Closed
opened 2025-12-29 18:24:08 +01:00 by adam · 1 comment
Owner

Originally created by @havedill on GitHub (Oct 21, 2019).

Environment

  • Python version: 3.6.7
  • NetBox version: 2.6.6 (was also happening on 2.6.4)

Steps to Reproduce

  1. Create a custom field in the admin panel. In my case it was a bool called Production
  2. Attempt to query API with filter for field value of true or false
    http://netbox.company.com/api/virtualization/virtual-machines/?cf_Production=false

I have tried this with both "loose" and "exact" filtering settings on the custom item.

I would expect hosts with the cf_Production value set as false to return.

When you do not try to do a cf_ query, you can see the values exist;

            "custom_fields": {
                "DNSAlias": null,
                "Production": false
            },

No return at all.

Originally created by @havedill on GitHub (Oct 21, 2019). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.7 * NetBox version: 2.6.6 (was also happening on 2.6.4) ### Steps to Reproduce 1. Create a custom field in the admin panel. In my case it was a **bool** called Production 2. Attempt to query API with filter for field value of true or false http://netbox.company.com/api/virtualization/virtual-machines/?cf_Production=false I have tried this with both "loose" and "exact" filtering settings on the custom item. <!-- What did you expect to happen? --> I would expect hosts with the cf_Production value set as false to return. When you do not try to do a cf_ query, you can see the values exist; ``` "custom_fields": { "DNSAlias": null, "Production": false }, ``` <!-- What happened instead? --> No return at all.
adam closed this issue 2025-12-29 18:24:08 +01:00
Author
Owner

@havedill commented on GitHub (Oct 22, 2019):

I found out why i was not getting returns.

For custom field querying of boolean values you need to search for a 1 or a 0. I was confused because i was expecting to filter for what i saw in the json netbox was returning. Perhaps the documentation should be updated to clarify this?

?cf_Production=1 works for True
?cf_Production=0 works for False

@havedill commented on GitHub (Oct 22, 2019): I found out why i was not getting returns. For custom field querying of boolean values you need to search for a 1 or a 0. I was confused because i was expecting to filter for what i saw in the json netbox was returning. Perhaps the documentation should be updated to clarify this? ?cf_Production=1 works for True ?cf_Production=0 works for False
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2965