JC Briar
unread,Sep 25, 2012, 12:03:21 PM9/25/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Okay, this may not be the most efficient implementation, but it works:
# create temporary file
tmpfile = tempfile.TemporaryFile()
write to tmpfile
# wrap temporary file with django.core.files.File
fileContents = django.core.files.File(tmpfile)
fileContents.size = tmpfile.tell() # admittedly, a bit of a hack
# create and save new Model
model = Chart(**kwargs)
model.image.save(fn, fileContents)