Reference Information. I start with Django and have limited experience with Python, so please bear with me. I wrote a Python script that runs periodically (in a cron job) to store data in a SQLite3 database, from which I would like to read and generate images using Matplotlib (more precisely, with Basemap). It started as an interest in learning Python and creating an “interesting” project. I choose the Django framework because it seems reasonably well-documented, although I was pleasantly surprised by web.py because of its “lightness” in its requirements (but the allowed documentation in web.py makes it a little harder to get started); but at the moment I’m not completely behind the bounds.
An example in question 1874642 is what I'm looking for, with creating an image "on the fly" without having to write it to disk (and therefore have to deal with the periodic cleaning of the generated files).
However, it is not clear to me how the generated image can be included in the template, instead of just the browser showing the image. From the training material, I suggest that it should be possible to represent the variables included in some django.template.Context, in django.http.HttpResponse, but the reference example shortens it by responding directly with the Mime object, rather than creating it with the context.
So I ask:
Do I need to call print_pngMatplotlib on the generated object FigureCanvas? Or is it FigureCanvascopied "non-printable" to the context, so that in the Django template I explicitly write an HTML tag imgand manually put the tag attributes?
I get the impression that I have to write the Canvas to disk (i.e. do canvas.print_figure("image.png")), so the HTML tag imgsees it in the Django template. But I want to be sure that there is no "more manageable way", i.e. Image transfer toContext "" . , , Django (, , ). , , , , , , ( ).
.