I am having images in my media folder and I want to display them but Django is not displaying images other than static folder. In my setting
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR,'static'),]
MEDIA_ROOT = BASE_DIR
MEDIA_URL = '/media/'
In my urls.py after url pattern I added this
+ static(MEDIA_URL, document_root=MEDIA_ROOT)
In my templates
<img class="card-img-top" style="" src="{{result.object.thumbnail.url}}" alt=""></a>
<p>{{result.object.thumbnail.url}}</p>
It is showing the correct path but not showing the image, I am unable to figure out the problem. Thanks
Your MEDIA_ROOT
have the path of the root of your project. You must join to it, the direcotry of your media
. (I suppose media/
is the directory name where you upload all your media)
I think you should have your MEDIA_ROOT
like that.
MEDIA_ROOT = os.path.join(BASE_DIR,'media')