Answer the question
In order to leave comments, you need to log in
Why is the image not loading in Django?
Hello everyone, here's a problem. When I upload an image to the server, I want to have a default image, but if I set:
photo = models.ImageField(upload_to='photo/%Y/%m/%d', default='default.jpg', blank=True, null=True, verbose_name='Картинка')
{% if i.photo %}
<img src="{{ i.photo.url }}" alt="" width="350" class="mr-3">
{% else %}
<img src="default.jpg" alt="" class="mr-3">
{% endif %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question