I understand this question in two ways.
One, if you just want to display the image on a template then simply use the src
attribute of the img
element and set that URL
Secondly, if you want to pass the image from your views.py
to the template then follow the method here - How can I pass an image to a template in Django?
The URL
of the image is sufficient. In your relevant views.py
method add a request call to the URL and download the image and pass the data as context, example call below.
import requests
url = "https://images-na.ssl-images-amazon.com/images/I/71ftMiKUwbL._SL1500.jpg"
response = requests.get(url)
if response.status_code == 200:
with open("/Users/apple/Desktop/sample.jpg", 'wb') as f:
f.write(response.content)