Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static URLs for images #1339

Closed
koeaw opened this issue Nov 4, 2024 · 0 comments · Fixed by #1381 or #1411
Closed

Static URLs for images #1339

koeaw opened this issue Nov 4, 2024 · 0 comments · Fixed by #1381 or #1411
Labels
assets Static files, components defining or contributing to appearance bug Something isn't working (properly, as expected, at all)

Comments

@koeaw
Copy link
Contributor

koeaw commented Nov 4, 2024

The Git and Swagger icons in the footer load fine for me, but cause errors when trying to access the "Static Files" tab in Django Debug Toolbar:

django.core.exceptions.SuspiciousFileOperation: The joined path (/img/Swagger-logo.png) is located outside of the base path component (/PATH_TO_VENV/lib/python3.11/site-packages/apis_override_select2js/static)

The toolbar only shows a non-descript "400: Bad Request" message.

Removing the leading slashes in the image paths:

{% if swagger_ui %}
<a href="{{ swagger_ui }}" title="Swagger UI">
<img src="{% static "/img/Swagger-logo.png" %}" height="24px">
</a>
{% endif %}
{% git_repository_url as repository_url %}
{% if repository_url %}
<a href="{{ repository_url }}" title="Git repository">
<img src="{% static "/img/Git-Icon-1788C.png" %}" height="24px">
</a>

(following the pattern by which other static files are referenced) seems to solve the issue.

@koeaw koeaw added bug Something isn't working (properly, as expected, at all) assets Static files, components defining or contributing to appearance labels Nov 12, 2024
b1rger added a commit that referenced this issue Nov 13, 2024
The leading slashes seem to lead to confusing errors from the django
debug toolbar and the `url` method of the configured storages remove it
anyway:
https://github.com/django/django/blob/d71c588d83e58e83bdd9ea8bf03724d10f02a8bd/django/core/files/storage/filesystem.py#L225

Closes: #1339
b1rger added a commit that referenced this issue Nov 13, 2024
The leading slashes seem to lead to confusing errors from the django
debug toolbar and the `url` method of the configured storages remove it
anyway:
https://github.com/django/django/blob/stable/5.1.x/django/core/files/storage/filesystem.py#L225

Closes: #1339
@b1rger b1rger closed this as completed in d657a98 Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assets Static files, components defining or contributing to appearance bug Something isn't working (properly, as expected, at all)
Projects
None yet
1 participant