简体   繁体   中英

Image is not showing in python django project

Image is not showing in python django project due to hardware issue every code is right, images fluctuated how this can be resolved??

<div class="owl-carousel" id="slider1">
      {% for b in bottomwears %}
        <a href="{% url 'product-detail' b.id %}" class="btn"><div class="item"><img src="{{b.product_image.url}}" alt="" height="300px"><span class="fw-bold">{{b.title}}</span><br><span class="fs-5">Rs. {{b.discounted_price}}</span></div></a>
      {% endfor %}
     </div>

Below is the screen shoot of website where image is not shown.

在此处输入图像描述

Model Code

class Product(models.Model):
 title = models.CharField(max_length=100)
 selling_price = models.FloatField()
 discounted_price = models.FloatField()
 description = models.TextField()
 brand = models.CharField(max_length=100)
 category = models.CharField( choices=CATEGORY_CHOICES, max_length=2)
 product_image = models.ImageField(upload_to='productimg')
  1. Have you configured MEDIA_ROOT and MEDIA_URL in settings.py file?
  2. You can do an Inspect on image and know the URL of the image in the HTML that it is pointing to. This way you could know the issue.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM