-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom fields - Allow use of query params for filtering object selection #16782
Comments
Thanks for your interest in helping improve NetBox. Your proposal and use case look good enough to work with, so I'm moving your issue along to |
Hi Jeff, I've done a proof-of-concept test that worked, so I'm happy work on a PR. rough plan is:
|
Hi @jeffgdotorg, just checking on the status of this. Can I provide a PR? |
@samk-acw thanks for your interest, I've assigned this to you. |
It appears this FR was tagged for implementation prematurely. Introducing a new field on a model can only be done in a new minor release: This should have been tagged for milestone assignment. Unfortunately we're in the process of rolling up the last pieces of open work for v4.1 right now. @samk-acw if you'd like to rebase your PR #16957 off of the |
Hi @jeremystretch, thanks for clarifying, I've deleted my original branch and done a new PR based from the feature branch now. |
This is a good reminder that we really need to get #14656 implemented. The custom field form is a mess. |
* Fixes #16782: Add object filtering for custom fields * Add validation for related_object_filter * Extend documentation & misc cleanup --------- Co-authored-by: Jeremy Stretch <[email protected]>
NetBox version
v4.0.6
Feature type
Change to existing functionality
Proposed functionality
Object type custom fields are very useful for creating new relationships between objects, but it has no ability to filter the selection list, any object of that type can be selected which may not be desirable depending on the intended purpose of the custom field.
The DynamicModelChoice mixins already support filtering the API requests using the query_params dict, I propose that this be added as an option to specify in the custom field definition.
Use case
Allowing filtering of the object choice selection would allow additional business logic to be applied and provide a more intuitive experience for the end user who is using the field.
For example, I have a custom field defined on Circuits to select an IP Address - with a query params definition I could limit it to show only 'active' IP addresses, and chain it to tenant field with $tenant to only list IPs that are assigned to the tenant of that circuit.
Database changes
CustomField model will need an additional field to store the parameter
External dependencies
none
The text was updated successfully, but these errors were encountered: