[Django]-How to properly show image stored from a remote file server to a django HTML template?

0👍

In your template instead of:

<img class="imgView" src="{{dashboard_image}}" alt="Dashboard画面.jpg"></img>

DO this:

<img class="imgView" src="{{dashboard_image.url}}" alt="Dashboard画面.jpg"></img>

0👍

<img class='img-responsive' src="{{ MEDIA_URL }}{{ item.image.url }}" />
or
<img class='img-responsive' src="{{ item.image.url }}" />

and in main urls.py

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)
👤saipy

Leave a comment