S
S
SISER1232020-07-24 19:39:10
Django
SISER123, 2020-07-24 19:39:10

How to add an image to a template using Django?

Hello, the question is not very difficult. I want to display an image on the site when I want through the html file, everything is fine, but when I start the Django server and go to the page, there is no image. I hope you can help, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shporsoft, 2020-07-27
@SISER123

{% static "myphoto.jpg"%}
Static is where your static files are stored. Images, JS CSS files. Don't forget to add
{% load static %} -- Django 3.0+
{% load staticfiles %} -- tag when using django 1.0+

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question