B
B
bituke2020-09-05 13:34:47
Django
bituke, 2020-09-05 13:34:47

How to display images on the site in django from the model?

There is a model in django that accepts text and an image (via imageField, respectively). There are already several objects in the database according to this model, all objects need to be displayed on the site with the image of the object itself. Display the text of the object like two fingers, but problems begin with the image. The path where django loads the image from the user is given below:

product_img = models.ImageField('Обложка товара', upload_to='catalog/imgproduct/img')


After I try to display an image from this path, I get nothing.
Here is how it is implemented in the html file:

<img class="product_img" src="{{a.product_img.url}}">


I think my problem is that I do not fully understand how statistical files work in janga, I would be grateful if you at least tell me where to dig, or directly tell me the answer.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question