New Custom Field Type for 'Generic' object relations. #3506

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

Originally created by @tyler-8 on GitHub (Mar 25, 2020).

Environment

  • Python version: v3.6.8
  • NetBox version: v2.6.12

Proposed Functionality

A new custom field type that introduces a generic way to link two objects together. When selecting the custom field type, there'd be a new selection called 'Object Relationship' and then a new dropdown where you'd have to select the object (circuit, site, IP address, etc) that you'd like the custom field value to point to.

Use Case

Overall this would allow users to create object relationships where they don't already exist in Netbox. In many cases, resorting to tags may not make sense as you'd end up with N-number of unique tags that only touch a couple objects - and even then don't show the direct relationship without some sort of external documentation.

One example: Link IP address and/or interface info with circuits where the L3 and L2 terminate at different points in the path; such as the physical termination being the switch, but the IP address and VLAN "terminate" on a router interface connected to the switch via a trunk.

There have been a number of FRs for VM-related features that just didn't make sense in the overall Netbox ecosystem, but I can see this helping to resolve a lot of 'missing links' for users that aren't cleanly helped by tags, but would be overkill to implement using the upcoming plugins functionality.

Process example:

  1. Create new custom field on circuits > circuit
  2. Type is 'Model relationship'
  3. Name is "Circuit IP"
  4. Select related object type ipam > ip address
  5. Click save
  6. Find target circuit and click edit
  7. Search for target IP in Select2 dropdown and click to select
  8. Save circuit
  9. IP now shows in Custom Fields section of Circuit Detail page

Database Changes

I think most (if not all) of the changes would be purely in the custom field space. Django does have the ability to do generic relationships and as Netbox is already utilizing the Content Types functionality, I suspect this should be doable without major surgery.

External Dependencies

N/A (unless there is a well-supported Django plugin that helps with this kind of thing)

Originally created by @tyler-8 on GitHub (Mar 25, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. 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: v3.6.8<!-- Example: 3.6.9 --> * NetBox version: v2.6.12<!-- Example: 2.7.3 --> <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality A new custom field type that introduces a generic way to link two objects together. When selecting the custom field type, there'd be a new selection called 'Object Relationship' and then a new dropdown where you'd have to select the object (circuit, site, IP address, etc) that you'd like the custom field value to point to. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case Overall this would allow users to create object relationships where they don't already exist in Netbox. In many cases, resorting to tags may not make sense as you'd end up with N-number of unique tags that only touch a couple objects - and even then don't show the direct relationship without some sort of external documentation. One example: Link IP address and/or interface info with circuits where the L3 and L2 terminate at different points in the path; such as the physical termination being the switch, but the IP address and VLAN "terminate" on a router interface connected to the switch via a trunk. There have been a number of FRs for VM-related features that just didn't make sense in the overall Netbox ecosystem, but I can see this helping to resolve a lot of 'missing links' for users that aren't cleanly helped by tags, but would be overkill to implement using the upcoming plugins functionality. Process example: 1) Create new custom field on `circuits > circuit` 2) Type is 'Model relationship' 3) Name is "Circuit IP" 4) Select related object type `ipam > ip address` 5) Click save 6) Find target circuit and click edit 7) Search for target IP in Select2 dropdown and click to select 8) Save circuit 9) IP now shows in Custom Fields section of Circuit Detail page <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes I think most (if not all) of the changes would be purely in the custom field space. Django does have the ability to do generic relationships and as Netbox is already utilizing the Content Types functionality, I suspect this should be doable without major surgery. <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies N/A (unless there is a well-supported Django plugin that helps with this kind of thing)
adam closed this issue 2025-12-29 18:29:34 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 26, 2020):

I appreciate the thoroughness of your feature request, however no further extensions to the custom fields model will be undertaken in the near future, as development needs to focus on other areas. Once the existing backlog has been processed, we can begin thinking about how custom fields might be better implemented to accommodate changes such as this, but that is a long time away.

@jeremystretch commented on GitHub (Mar 26, 2020): I appreciate the thoroughness of your feature request, however no further extensions to the custom fields model will be undertaken in the near future, as development needs to focus on other areas. Once the existing backlog has been processed, we can begin thinking about how custom fields might be better implemented to accommodate changes such as this, but that is a long time away.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3506