Skip to content
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

15794 Make "related objects" dynamic #15876

Merged

Conversation

alehaa
Copy link
Contributor

@alehaa alehaa commented Apr 28, 2024

Fixes: #15794

Instead of hardcoding relationships between models for the detail view, they are now dynamically generated.

Known limitations

  1. If a related model doesn't have a list view, rendering of the related objects pane will fail. This limitation was already present before, but related models listed were explicitly chosen to do so. For all views shipped with NetBox I've added a filter if needed (omit parameter). However, external plugins might trigger this unintentionally, when named view is not available, but the relationship has not been setup with related_name='+' parameter. Switching to verified_view in the panel's template should resolve this, but might decrease performance slightly.

  2. If a model introduces several relations to another model, they will all be listed with the same model name but different URL query parameters. This is not the case for models included in NetBox. As before, plugin developers can still use an extra panel for this special purpose and extra context about the different types of relationships.

alehaa added 2 commits April 28, 2024 14:25
Instead of hardcoding relationships between models for the detail view,
they are now dynamically generated.
jeremystretch and others added 3 commits May 9, 2024 13:50
Instead of providing a rarely used hook method, additional related
models can now be passed directly to the lookup method.
netbox/circuits/views.py Outdated Show resolved Hide resolved
netbox/dcim/views.py Show resolved Hide resolved
netbox/dcim/views.py Outdated Show resolved Hide resolved
netbox/dcim/views.py Outdated Show resolved Hide resolved
netbox/ipam/views.py Outdated Show resolved Hide resolved
netbox/ipam/views.py Outdated Show resolved Hide resolved
alehaa added 4 commits June 10, 2024 21:12
ASNs have ManyToMany relationships and therefore can't used automatic
resolving. Explicit relations have been restored as before.
@alehaa alehaa requested a review from jeremystretch June 11, 2024 20:23
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alehaa!

@jeremystretch jeremystretch merged commit 5353f83 into netbox-community:develop Jun 12, 2024
3 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 13, 2024
@alehaa alehaa deleted the feature/15794-related-objects branch July 16, 2024 21:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the "Related Objects" pane of all models dynamic
2 participants