DJANGO - how to retrieve picture from database(sqlite) to show it on html

I have loaded the pictures to database(sqlite) and now, how to get that photo in html, can you guys tell me the steps to get there, thanks in advance

I want to grab the picture from database and show it in the html.

To show uploaded images in template:

In html file:

<img src="/media/{{image}}" /> #image is a model field name.

This is the way you can view uploaded image in template.

Your images are stored in your static files folder and not directly in the database. I assume you are using an ImageField to store the image in your model. Something like this:

image = models.ImageField(upload_to="static/images/", null=True, blank=True)

If that's the case, in order to display it in one of your templates what you have to do is refer to the image url:

<img src="{{ mymodel.url }}" />
Back to Top