Here is what i tried to do:
in my settings.py:
TEMPLATES = [
...
'OPTIONS': {
'context_processors': [
...
'django.template.context_processors.media',
],
},
},
]
MEDIA_ROOT = os.path.join(BASE_DIR, 'img')
MEDIA_URL = '/img/'
i have also added this in my main urls.py:
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
And here's the code in my template:
<img
src="{{ product.image.url }}"
alt="Not available"
height="188px"
style="margin: 10px 0"
width="188px"
/>
Edit ...
I solved my problem :)
This is what is did
src="{{ MEDIA_URL }}{{ product.image.url }}"
i added {{ MEDIA_URL }} in src of my <img> tag.