From e494d7bb222f472411436f83d4acc72c19d34297 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 21 Nov 2022 08:06:12 -0500 Subject: [PATCH] Fixes #10982: Catch NoReverseMatch exception when rendering tabs with no registered URL --- docs/release-notes/version-3.4.md | 1 + netbox/utilities/templatetags/tabs.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.4.md b/docs/release-notes/version-3.4.md index 1d57660bd..94939ff5e 100644 --- a/docs/release-notes/version-3.4.md +++ b/docs/release-notes/version-3.4.md @@ -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) diff --git a/netbox/utilities/templatetags/tabs.py b/netbox/utilities/templatetags/tabs.py index 65f52167d..3e5bf2127 100644 --- a/netbox/utilities/templatetags/tabs.py +++ b/netbox/utilities/templatetags/tabs.py @@ -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 @@ -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,