def get_or_404(
    queryset: type[_ModelT] | QuerySet[_ModelT] | Manager[_ModelT],
    pk: Any,
) -> _ModelT:
    """
    A simpler version of django.shortcuts.get_object_or_404()
    Produces a better error message.
    """

    if hasattr(queryset, "_default_manager"):
        queryset = queryset._default_manager.all()

    model_type = queryset.model

    try:
        return queryset.get(pk=pk)
    except model_type.DoesNotExist as ex:
        readable_model_name = queryset.model._meta.verbose_name.capitalize()
        raise NotFound(f"{readable_model_name} {pk} does not exist") from ex

    A simpler version of django.shortcuts.get_object_or_404()
    Produces a better error message.
    
cvat/apps/engine/view_utils.py