From 87e910421cbd2d830f57c12510d2363ffd4c74c3 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 30 Jun 2025 09:25:38 -0400 Subject: [PATCH] clone_button tag should fail silently if view name is invalid --- netbox/utilities/templatetags/buttons.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/netbox/utilities/templatetags/buttons.py b/netbox/utilities/templatetags/buttons.py index c1003d249..977ad8fd2 100644 --- a/netbox/utilities/templatetags/buttons.py +++ b/netbox/utilities/templatetags/buttons.py @@ -74,17 +74,19 @@ def bookmark_button(context, instance): @register.inclusion_tag('buttons/clone.html') def clone_button(instance): - url = reverse(get_viewname(instance, 'add')) + # Resolve URL path + viewname = get_viewname(instance, 'add') + try: + url = reverse(viewname) + except NoReverseMatch: + return { + 'url': None, + } - # Populate cloned field values + # Populate cloned field values and return full URL param_string = prepare_cloned_fields(instance).urlencode() - if param_string: - url = f'{url}?{param_string}' - else: - url = None - return { - 'url': url, + 'url': f'{url}?{param_string}' if param_string else None, }