Home > Enterprise >  Image is not loading in Django Template
Image is not loading in Django Template

Time:08-10

I am having a Django HTML page. I would like to display an image in an HTML file. I am returning like this.

in views.py

params = {
    'obj': obj,
    'data':data,
}
return render_to_string('records/record.html', params), obj

In html file

 <img src="{{data.image.path}}">

While logging what I am getting data.image.path like this

https://document.s3.amazonaws.com/others/path/20220809-150420-Screenshot-(97).png?Amz-Expires=600&X-Amz-SignedHeaders=host&X-Amz-Signature=6037f61de9173fcf2a2b556ef81e

In Django html page it replacing & to &amp.

CodePudding user response:

Try changing {{data.image.path}} to {{data.image.url}}

  • Related