FLYAX
1
Hey guys,
I want to show an image on my page and I guess I messed something up with the paths.

This is my filetree and as youc an see there is the Picture.jpeg in the file Folder in the Media Folder
In my template I wont to show that image with this code:
<img src="DivusX/media/{{ image }}"/>
But the picture doesnt show up.
Btw the output from {{ image }} is file/Picture.jpeg so thats not the error.
Thanks for the help
qvisty
2
Try to move it to media folder.
It looks like it is in a file subfolder
FLYAX
3
the path is navigating into that thats correct how it is
What are your BASE_DIR, MEDIA_ROOT, and MEDIA_URL settings? Your URL does not need to correspond to the physical directory structure.
FLYAX
5
MEDIA_URL = 'DivusX/StartSite/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
BASE_DIR = Path(__file__).resolve().parent.parent
See the difference between the URLs?
FLYAX
8
<img src="DivusX/StartSite/media/{{ image }}"/>
that doesnt work either
You need to start the src url with a /
otherwise it’s considered a relative url and will be appended to the current pages url.