mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00
clone_button tag should fail silently if view name is invalid
This commit is contained in:
parent
0da5000a2c
commit
87e910421c
@ -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,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user