From 9f01962c4e26facdd44ce55c298af837de5f36dc Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 10 Jan 2024 23:37:29 +1100 Subject: [PATCH] Handle case where ref_url is invalid (#6186) --- InvenTree/part/templatetags/inventree_extras.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 9abd6748bf..cdb63aacd1 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -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'{ref}') + try: + ref_url = reverse(url_name, kwargs={'pk': pk}) + return mark_safe(f'{ref}') + except NoReverseMatch: + return None @register.simple_tag()