I’m using Django to create a web app where some parameters are input and plots are created. I want to have a link which will be to download ALL the plots in a zip file. To do this, I am writing a view which will create all the plots (I’ve already written views that create each of the single plots and display them), then zip them up, saving the zip file as the response object.
One way I could do this is to create each plot, save it as a pdf file to disk, and then at the end, zip them all up as the response. However, I’d like to sidestep the saving to disk if that’s possible?
Cheers.
This is what worked for me, going by Krzysiek’s suggestion of using
StringIO. Herecanvasis acanvasobject created by matplotlib.The zipping part of all of this was taken from https://code.djangoproject.com/wiki/CookBookDynamicZip