Currently, I am getting the HTTPRssponse using:
def imgResponse(valid_image):
try:
with open(valid_image, "rb") as f:
return HttpResponse(f.read(), content_type="image/jpeg")
except:
red = Image.new('RGBA', (1, 1), (255,0,0,0))
response = HttpResponse(content_type="image/jpeg")
red.save(response, "JPEG")
return response
I am not sure how to now display this in my HTML template. What I've tried is to pass it in my context:
context = {"other_context_part": other_context_part, "my_image": my_image}
Then I have the following in my template:
{{ my_image }}
I am generating this image dynamically and it is not static. How do I display my HTTPResponse?