Hi all, I'm trying to put together a little site that handles document uploads. There needs to be a little bit of processing of the document I call save().
I'm putting this in as part of the model, since I want it to work
in the admin interface as well as via a webform, so my code
currently looks like this:
def save(self, force_insert=False, force_update=False):
super(Document, self).save(force_insert, force_update)
self.document_data = process_file(self.document_upload)
super(Document, self).save(force_insert, force_update)
Which, you know, is horrible. self.document is a FieldFile object,
but doesn't seem to contain the actual file data until super.save
has been called.
Is there a way to either:
access the uploaded document directly before it is committed
to disk? (I understand django stores it in memory unless it is
large)
Or:
write the upload to disk without writing to the database, then
calling a save which only does the db transaction.
Alternatively, is there another approach entirely that I should be
taking? This is a first approximation, so I am very prepared to be
utterly wrong.
Many thanks
Stoo
signature.asc
Description: Digital signature

