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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user