Handle case where ref_url is invalid (#6186)

This commit is contained in:
Oliver 2024-01-10 23:37:29 +11:00 committed by GitHub
parent a23235400d
commit 9f01962c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -539,8 +539,11 @@ def authorized_owners(group):
@register.simple_tag()
def object_link(url_name, pk, ref):
"""Return highlighted link to object."""
ref_url = reverse(url_name, kwargs={'pk': pk})
return mark_safe(f'<b><a href="{ref_url}">{ref}</a></b>')
try:
ref_url = reverse(url_name, kwargs={'pk': pk})
return mark_safe(f'<b><a href="{ref_url}">{ref}</a></b>')
except NoReverseMatch:
return None
@register.simple_tag()