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 <noreply@anthropic.com>
This commit is contained in:
2026-10-13 15:08:50 +02:00
co-authored by Claude Opus 5.5
parent ffe594a5f9
commit e4d1383e8c
+2 -3
View File
@@ -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: