From e4d1383e8cf1152f869a64ec99c7eaec43950ee6 Mon Sep 17 00:00:00 2001 From: MrBlake Date: Tue, 13 Oct 2026 15:08:50 +0200 Subject: [PATCH] Pass a relative path to static() for device images A leading slash made static file finders, such as the one used by the debug toolbar with DEBUG = True, raise SuspiciousFileOperation on the Images page. The generated URL is unchanged. Verified on NetBox 4.7.2. Co-Authored-By: Claude Opus 5.5 --- netbox_topology_views/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/netbox_topology_views/utils.py b/netbox_topology_views/utils.py index 687dba4..c288880 100644 --- a/netbox_topology_views/utils.py +++ b/netbox_topology_views/utils.py @@ -29,9 +29,8 @@ else: def image_static_url(path: Path) -> str: - return static( - f"/{path.relative_to(Path(settings.STATIC_ROOT))}" - ) + # No leading slash: static file finders (e.g. the debug toolbar's) reject absolute paths. + return static(path.relative_to(Path(settings.STATIC_ROOT)).as_posix()) def get_image_from_url(url: str) -> str: