I have a form where I upload a file, and I generate a report out of it. The thing is, I would also like to make the report available for download, as an archive. I would like to somehow include the CSS and the JS ( that I inherit from my layout ) inside the report, but I don’t really know how to go about this.
So far, I am not storing the file ( the report’s being generated from ) on server side, I delete it after I’m done with it.
The only solution I could think of so far, was: from my archive generating view, use urllib to post to the form generating the report, save the response, and just rewrite the links to the stylesheet/JS files.
Is there a simpler way to go about this? Is there a way to keep some files on server side as long as the client’s session lives?
Use the HttpResponse in the view you use to show the generated report instead of posting with urllib. If you have something along the lines of
Then use the response object to create an archive
You can find all you need to know about HttpResponse in the Django docs.
Although this might work for you I doubt that is what you are really after, maybe what you are really looking for is to generate a pdf report using ReportLab?