Fixes #21173: Fix plugin menu registration order timing issue #21248
+46
−35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #21173: Fix plugin menu registration order timing issue
Summary
This PR fixes an issue where plugin menus registered later in the Django app initialization process were not appearing in the NetBox navigation sidebar. The problem occurred because the
MENUSlist was built at module import time, before all plugins had completed theirready()methods.Problem
When multiple plugins register menus via
navigation.pyandPluginConfig.ready(), only the first few plugins' menus would appear in the navigation sidebar. The missing menus were properly registered in the plugin registry, but were not included in the finalMENUSlist.Root Cause:
netbox/navigation/menu.pywas imported during Django startup (insettings.py)MENUSlist was built by iterating overregistry['plugins']['menus']ready()methods at that pointMENUSwas already built, so they were excludedSolution
Converted the static
MENUSlist to a dynamicget_menus()function that builds the menu list on-demand at request time (when the navigation template tag is rendered). This ensures all plugins have completed theirready()methods before the menus are assembled.Changes Made:
MENUSlist withget_menus()function innetbox/navigation/menu.pynetbox/utilities/templatetags/navigation.pyto callget_menus()instead of importingMENUSImpact
Testing