Explore alternative implementations for multi-model parent relationships #4924

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

Originally created by @jeremystretch on GitHub (May 18, 2021).

Proposed Changes

There are several areas in NetBox where an object can be assigned to multiple types of "parent" object. Some examples include:

  • VLANGroup scope
  • Service device/VM
  • IPAddress interface

As we continue to extend the data model, this type of relationship will become more common. The current implementation generally employs a separate ForeignKey field for each model, to overcome performance limitations concerning the use of GenericForeignKey. Moving forward, we should look into alternative implementations that might be easier to maintain without sacrificing performance significantly.

Justification

If we can identify a suitable solution, this will allow us to support multi-model parent relationships without needing to add multiple discrete ForeignKey fields, reducing the long-term maintenance burden.

Originally created by @jeremystretch on GitHub (May 18, 2021). ### Proposed Changes There are several areas in NetBox where an object can be assigned to multiple types of "parent" object. Some examples include: * VLANGroup scope * Service device/VM * IPAddress interface As we continue to extend the data model, this type of relationship will become more common. The current implementation generally employs a separate ForeignKey field for each model, to overcome performance limitations concerning the use of GenericForeignKey. Moving forward, we should look into alternative implementations that might be easier to maintain without sacrificing performance significantly. ### Justification If we can identify a suitable solution, this will allow us to support multi-model parent relationships without needing to add multiple discrete ForeignKey fields, reducing the long-term maintenance burden.
adam added the pending closurestatus: under reviewtype: housekeeping labels 2025-12-29 19:22:19 +01:00
adam closed this issue 2025-12-29 19:22:20 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 18, 2021):

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 (Jul 18, 2021): 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 (Aug 17, 2021):

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 (Aug 17, 2021): 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#4924