[Answer]-Image in Django Template doesn't appear

1👍

you shoud define MEDIA_ROOT in your settings file:

MEDIA_ROOT = (os.path.join(os.path.dirname(__file__), '..', 'appl_name/Static').replace('\\', '/'))

your images must be in appl_name/Static/Pictures/ dir

you template should look like this:

{% load staticfiles %}
<img src = {% static 'Pictures/teste.jpg' %} />

0👍

In your base folder for your django project you usually want to have a “media” or “static” folder. Here you will save your images. Then in settings.py define STATIC_ROOT = ‘static’ . define STATIC_URL = ‘/static/’ . and finally in your HTML IMG tag define it as such <img src="{% STATIC_URL %}example_image.jpg > . that should work n fix ur image problem.

Leave a comment