B
B
BigDB2021-05-15 12:30:09
Django
BigDB, 2021-05-15 12:30:09

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='Картинка')

then, the Default image is always loaded.
Decided to go through:
{% if i.photo %}
              <img src="{{ i.photo.url }}" alt="" width="350" class="mr-3">
{% else %}
              <img src="default.jpg" alt="" class="mr-3">
{% endif %}

again a bummer, it doesn’t work, I can’t specify the right path in any way (even completely copying the path to the image I get a void.
The third time I decided to go through static and again a bummer.

Link to Github: https://github.com/DarAnod-B/site .git

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BigDB, 2021-05-15
@BigDB

Reply to: Why is an image being loaded via a Django form?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question