I want to generate an image with a static url in a view, then render it in a template. I use mark_safe
so that the HTML won't be escaped. However, it still doesn't render the image. How do I generate the image tag in Python?
from django.shortcuts import render
from django.utils.safestring import mark_safe
def check(request):
html = mark_safe('<img src="{% static "brand.png" %}" />')
return render(request, "check.html", {"image": html})
Rendering it in a template:
{{ image }}
renders the img tag without generating the url:
<img src="{% static "brand.png" %} />