Add API filter for object names in Contact assignments #10133

Closed
opened 2025-12-29 21:27:17 +01:00 by adam · 4 comments
Owner

Originally created by @Pixelshifter on GitHub (Aug 23, 2024).

NetBox version

v4.0.9

Feature type

Data model extension

Proposed functionality

Add a filter for 'object.name' for contact-assignments.

In comparison with for instance Virtual Machines, where you can search on a name, not even using a filter, that is not possible with Contact Assignments. I would like to search on Contact assigment object names, which is not possible at this time.

Use case

I can't ask the API for the contact and attributes for an object, in my specific use-case, a Tenant. Which means i have to gather all contact-assignments. This is possible however, I have to client-side filter the output. I would like Netbox to do that heavy lifting for me. It's also inconvenient when using the UI that I can't simply search on an object name. When using contact-assignment via the API-endpoint however, the information is there, but I can't filter on it.

Database changes

Not quite sure, I think just a change on the API filtering side is needed.

External dependencies

No response

Originally created by @Pixelshifter on GitHub (Aug 23, 2024). ### NetBox version v4.0.9 ### Feature type Data model extension ### Proposed functionality Add a filter for 'object.name' for contact-assignments. In comparison with for instance Virtual Machines, where you can search on a name, not even using a filter, that is not possible with Contact Assignments. I would like to search on Contact assigment object names, which is not possible at this time. ### Use case I can't ask the API for the contact and attributes for an object, in my specific use-case, a Tenant. Which means i have to gather all contact-assignments. This is possible however, I have to client-side filter the output. I would like Netbox to do that heavy lifting for me. It's also inconvenient when using the UI that I can't simply search on an object name. When using contact-assignment via the API-endpoint however, the information is there, but I can't filter on it. ### Database changes Not quite sure, I think just a change on the API filtering side is needed. ### External dependencies _No response_
adam closed this issue 2025-12-29 21:27:17 +01:00
Author
Owner

@renatoalmeidaoliveira commented on GitHub (Apr 25, 2025):

After some research in that issue, I think that might be a bit challenging to implement.
The ContatctAssignments uses a GFK relation with ContentType so implementing a prefetch to query objects name may be equivalent to query all NetBox models.
There also some problems with quering names, because name isn't a reliable attribute, i.e. not all models have that attribute.
So to add that feature, it might need to add another field to ContatctAssignments derived from the Assigned Object, maybe its __str__ representation.

@renatoalmeidaoliveira commented on GitHub (Apr 25, 2025): After some research in that issue, I think that might be a bit challenging to implement. The `ContatctAssignments` uses a GFK relation with `ContentType` so implementing a prefetch to query objects name may be equivalent to query all NetBox models. There also some problems with quering names, because `name` isn't a reliable attribute, i.e. not all models have that attribute. So to add that feature, it might need to add another field to `ContatctAssignments` derived from the Assigned Object, maybe its `__str__` representation.
Author
Owner

@abhi1693 commented on GitHub (May 3, 2025):

@jeremystretch I'd like to take this.

@abhi1693 commented on GitHub (May 3, 2025): @jeremystretch I'd like to take this.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 2, 2025):

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 (Aug 2, 2025): 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/main/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Sep 2, 2025):

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 (Sep 2, 2025): 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#10133