I'm writing an app that will generate, store, and display chart images. The idea is this: When a site visitor requests a given chart image, the app will check to see if it already exists. If not, the app will generate and store the necessary image before displaying it.
Towards that end, I have a Chart model with an ImageField: class Chart(models.Model): pattern = models.ForeignKey(Pattern) symbols = models.BooleanField() rguides = models.BooleanField('row guides') cguides = models.BooleanField('column guides') hreps = models.SmallIntegerField('horizontal repeats', choices = REPS_CHOICES) vreps = models.SmallIntegerField('vertical repeats', choices = REPS_CHOICES) image = models.ImageField(upload_to = 'charts/%Y/%m') So far, so good. From the admin interface, I and view my Charts and upload image files. Here's my question: What's the best way of saving images that I generate? >From what I've read, it seems that my only choice is to create a temporary file, wrap it in a ImageFile object, use it in the construction of a new Chart, call save() on the chart, and delete the temporary file. But given that my image-generation code writes to any file-like object, this strikes me as inefficient. Is there any way to create an ImageFile object and retrieve from it a writable fobj? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kzK_EAJnd-0J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.