API filtering - Filter/Get where a field is unset/None/null #6183

Closed
opened 2025-12-29 19:37:47 +01:00 by adam · 2 comments
Owner

Originally created by @ITJamie on GitHub (Mar 8, 2022).

NetBox version

3.1.9

Feature type

Change to existing functionality

Proposed functionality

ability to get or filter objects via api where a field is null/None/unset
Ive attempted this via the following uri's
https://demo.netbox.dev/api/dcim/devices/?cf_sw_version=null - django error - Cannot use None as a query value
https://demo.netbox.dev/api/dcim/devices/?cf_sw_version='' - no items
https://demo.netbox.dev/api/dcim/devices/?cf_sw_version=None - no items

interesting filtering a Date type custom field by null returns an error to supply a valid date rather than the django error above
https://demo.netbox.dev/api/dcim/devices/?cf_deployeddate=null

Use case

Trying to find objects which do not have fields set.
This was previously mentioned on https://github.com/netbox-community/pynetbox/issues/160 as a limitation of the API

Database changes

No response

External dependencies

No response

Originally created by @ITJamie on GitHub (Mar 8, 2022). ### NetBox version 3.1.9 ### Feature type Change to existing functionality ### Proposed functionality ability to get or filter objects via api where a field is null/None/unset Ive attempted this via the following uri's `https://demo.netbox.dev/api/dcim/devices/?cf_sw_version=null` - django error - `Cannot use None as a query value` `https://demo.netbox.dev/api/dcim/devices/?cf_sw_version=''` - no items `https://demo.netbox.dev/api/dcim/devices/?cf_sw_version=None` - no items interesting filtering a Date type custom field by `null` returns an error to supply a valid date rather than the django error above `https://demo.netbox.dev/api/dcim/devices/?cf_deployeddate=null` ### Use case Trying to find objects which do not have fields set. This was previously mentioned on https://github.com/netbox-community/pynetbox/issues/160 as a limitation of the API ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurestatus: needs ownerpending closure labels 2025-12-29 19:37:47 +01:00
adam closed this issue 2025-12-29 19:37:48 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 6, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jun 6, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jul 8, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jul 8, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6183