I am using matplotlib in a django app and would like to directly return the rendered image.
So far I can go plt.savefig(...), then return the location of the image.
What I want to do is:
return HttpResponse(plt.renderfig(...), mimetype="image/png")
Any ideas?
Django’s
HttpResponseobject supports file-like API and you can pass a file-object to savefig.Hence, you can return the image directly in the
HttpResponse.