I have my django app hosted on pythonanywhere. I am using weasyprint to generate a pdf and there is an image to be shown in my pdf. The error in the error log is "Failed to load image at /static/images/logo.png". When I try to open the same path as url, it shows me the image in the browser. Which means it is getting the path right but something else is wrong.
I have my static directory placed outside the app. And this path is added to the settings file.
My folder structure:
my_app
static
|__ css
|__ images
|__ logo.png
|__ js
templates
|__ my_app
|__ pdf.html
settings.py:
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS =[
STATIC_DIR,
]
pdf.html:
{% load static %}
<td><img class="my_logo" src="{% static 'images/logo.png' %}" alt="Temporarily Unavailable"></td>
collectstaticto fill destination folder - STATIC_ROOT. - Ivan Starostinmanage.py collectstaticto copy the static files from the static directory inside the project repository to the location from where they are served. - dirkgrotendirectory outside of the projectlooks like OP does not have such a directory. - Ivan Starostin