Skip to content

Commit

Permalink
Fixes #10982: Catch NoReverseMatch exception when rendering tabs with…
Browse files Browse the repository at this point in the history
… no registered URL
  • Loading branch information
jeremystretch committed Nov 21, 2022
1 parent 9774bb4 commit e494d7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/release-notes/version-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [#10957](https://github.com/netbox-community/netbox/issues/10957) - Add missing VDCs column to interface tables
* [#10973](https://github.com/netbox-community/netbox/issues/10973) - Fix device links in VDC table
* [#10980](https://github.com/netbox-community/netbox/issues/10980) - Fix view tabs for plugin objects
* [#10982](https://github.com/netbox-community/netbox/issues/10982) - Catch `NoReverseMatch` exception when rendering tabs with no registered URL

## v3.4-beta1 (2022-11-16)

Expand Down
8 changes: 7 additions & 1 deletion netbox/utilities/templatetags/tabs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import template
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch
from django.utils.module_loading import import_string

from netbox.registry import registry
Expand Down Expand Up @@ -36,9 +37,14 @@ def model_view_tabs(context, instance):
if attrs := tab.render(instance):
viewname = get_viewname(instance, action=config['name'])
active_tab = context.get('tab')
try:
url = reverse(viewname, args=[instance.pk])
except NoReverseMatch:
# No URL has been registered for this view; skip
continue
tabs.append({
'name': config['name'],
'url': reverse(viewname, args=[instance.pk]),
'url': url,
'label': attrs['label'],
'badge': attrs['badge'],
'is_active': active_tab and active_tab == tab,
Expand Down

0 comments on commit e494d7b

Please sign in to comment.