I have the following structure
my app/
|_my_app/
| |_templates/
|_static/
|_media/
|_utils/
|_main.py
|_manage.py
|_.gitignore
and having the in template.html
<img src="./media/image.png">
then it casts a GET 404 error Cannot find /media/image.png
.
I have also tried relative path (relative to the template i.e <img src="../../media/image.png">
.
Moving the media folder into static (and including {% load static %}
I can do
<img src="{% static '/media/image.png'">
without any issues.
- Why can't it find
./media/image.png
in the first part? - Is there a way to do the "static" trick but with another tag (say
media
) e.g<img src="{% media 'image.png' ">
to avoid absolute paths?