python - Error while displaying image from admin panel in django -


i trying upload image django admin panel , made following changes.however, getting error when tried load image in wine_list page , review_list.the images stored in media however, isnt being displayed:

page not found (404) request method: request url:    http://127.0.0.1:8000/static/media/download_1.jpg raised by:  django.views.static.serve 'media\download_1.jpg' not found 

here code wine_list

{% extends 'base.html' %}  {% block title %} <h2>wine list</h2> {% endblock %}  {% block content %} {% if wine_list %} {% load static %}  <div>     {% wine in wine_list %}      <div><ul>     <li>         <h4><a href="{% url 'reviews:wine_detail' wine.id %}">         {{ wine.name}}</a>          <br>         <a><img src="{% static wine.images.url %}" height="200"></a>           <br>         <br> 

here code image section in review_list:

{% extends 'base.html' %}  {% block title %} <h2>latest reviews</h2> {% load static %} {% endblock %}  {% block content %} {% if latest_review_list %} <div class="row">     {% review in latest_review_list %}     <div class="col-xs-6 col-lg-4">             <h4><a href="{% url 'reviews:review_detail' review.id %}">         {{ review.wine.name }}          </a></h4>  <br>        <a><img src="{% static review.wine.images.url %}" height="200"></a>     

urls.py winerama folder

from django.conf.urls import include, url django.contrib import admin django.conf import settings django.conf.urls.static import static  urlpatterns = [     url(r'^reviews/', include('reviews.urls', namespace="reviews")),     url(r'^admin/', include(admin.site.urls)),     url(r'^accounts/', include('registration.backends.simple.urls')),     url(r'^accounts/', include('django.contrib.auth.urls', namespace="auth")),  ]  if settings.debug:     urlpatterns += static(settings.static_url,document_root=settings.static_root)        urlpatterns += static(settings.media_url,document_root=settings.media_root) 

check setting file whether setup static image path:

static_url = '/static/' static_root = os.path.join(base_dir, 'static/') 

also check image file permission also. accessible anywhere.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -