diff --git a/horilla_crumbs/context_processors.py b/horilla_crumbs/context_processors.py index 9fa040363..2f7ba06d5 100644 --- a/horilla_crumbs/context_processors.py +++ b/horilla_crumbs/context_processors.py @@ -1,3 +1,4 @@ +import uuid from urllib.parse import urlparse from django.apps import apps @@ -8,6 +9,14 @@ from employee.models import Employee from horilla.urls import urlpatterns +def is_valid_uuid(uuid_string): + try: + uuid.UUID(uuid_string, version=4) + return True + except ValueError: + return False + + def _split_path(self, path=None): """Returns a list of the path components between slashes""" if not path: @@ -228,7 +237,7 @@ def breadcrumbs(request): new_dict = {"url": path, "name": item, "found": found} - if item.isdigit(): + if item.isdigit() or is_valid_uuid(item): # Handle the case when item is a digit (e.g., an ID) current_url = resolve(request.path_info) url_kwargs = current_url.kwargs