Skip to content Skip to sidebar Skip to footer

Django Static Media Not Showing Picture

after searching for a solution for hours which did not resolve my problem,I am posting this. The image from my media root is not showing up on my html. In chrome's console i get a

Solution 1:

It's a common mistake to mix up the static and media settings. In your case what you are actually dealing with is user uploaded MEDIA and not STATICs.

<imgsrc = "{{ instance.post.url}}"height="520"width="500"><br>

The settings that are most relevent are MEDIA_* settings described here https://docs.djangoproject.com/en/1.10/howto/static-files/

But more importantly, in your dev sever you need to enable the delivery of MEDIA by adding

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Post a Comment for "Django Static Media Not Showing Picture"