Can't search for empty field using __empty for dns_name for IP addresses #6408

Closed
opened 2025-12-29 19:40:19 +01:00 by adam · 3 comments
Owner

Originally created by @sol1james on GitHub (Apr 27, 2022).

Originally assigned to: @arthanson on GitHub.

NetBox version

3.2.1

Python version

3.10

Steps to Reproduce

I want to search for records that have no value in a field as per https://github.com/netbox-community/netbox/issues/6138. The url I'm using is:

https://netbox.mydomain/ipam/ip-addresses/?dns_name__empty=False

I also tried this with the description field for IP addresses and also the description field for a Device with the same results.

I created a discussion topic at https://github.com/netbox-community/netbox/discussions/9224 and Jeremy says it appears to be a bug.

Expected Behavior

I get a list of all the IP addresses that have dns_name defined (set to some value)

Observed Behavior

I get all IP addresses

Follow on question

Is __empty (or searching for the null field value) supposed to work for custom fields? I tested it in those too and couldn't get it to work

Originally created by @sol1james on GitHub (Apr 27, 2022). Originally assigned to: @arthanson on GitHub. ### NetBox version 3.2.1 ### Python version 3.10 ### Steps to Reproduce I want to search for records that have no value in a field as per https://github.com/netbox-community/netbox/issues/6138. The url I'm using is: `https://netbox.mydomain/ipam/ip-addresses/?dns_name__empty=False` I also tried this with the description field for IP addresses and also the description field for a Device with the same results. I created a discussion topic at https://github.com/netbox-community/netbox/discussions/9224 and Jeremy says it appears to be a bug. ### Expected Behavior I get a list of all the IP addresses that have dns_name defined (set to some value) ### Observed Behavior I get all IP addresses ### Follow on question Is __empty (or searching for the `null` field value) supposed to work for custom fields? I tested it in those too and couldn't get it to work
adam added the type: bugstatus: accepted labels 2025-12-29 19:40:19 +01:00
adam closed this issue 2025-12-29 19:40:20 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 27, 2022):

This is probably going to require improving our current approach to automatically generating lookup filters, as it needs to add a boolean filter (rather than a character filter).

@jeremystretch commented on GitHub (Apr 27, 2022): This is probably going to require improving our current approach to automatically generating lookup filters, as it needs to add a boolean filter (rather than a character filter).
Author
Owner

@github-actions[bot] commented on GitHub (Jun 27, 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. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jun 27, 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. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Jul 19, 2022):

This seems to be an issue with our custom empty lookup. Even though the lookup succeeds when used directly in a queryset filter, django-filters does not seem to recognize it:

django_filters.exceptions.FieldLookupError: Unsupported lookup 'empty' for field 'ipam.IPAddress.dns_name'.
@jeremystretch commented on GitHub (Jul 19, 2022): This seems to be an issue with our [custom `empty` lookup](https://github.com/netbox-community/netbox/blob/802d9d2b6ec178fbae7bfee1947af3af0589e538/netbox/extras/lookups.py#L4). Even though the lookup succeeds when used directly in a queryset filter, django-filters does not seem to recognize it: ``` django_filters.exceptions.FieldLookupError: Unsupported lookup 'empty' for field 'ipam.IPAddress.dns_name'. ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6408