Django admin process file after upload complete
How do I process any operation on file after its upload is completed?
I need to copy uploaded file on remote server immedeatly after upload, get
response from remote server and put it into database.
I have tried to do it in save_model of ModelAdmin like this:
class MyAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
obj.answer = remote_upload(obj.file.path)
obj.save()
remote_upload is self-written function, it successfully uploads a file, if
I run it directly. but it fails in save_model. obj.file.path returns an
MEDIA_PATH + filename and it looks like file is missing on moment of of
save_model executing.
How should I copy file the right way?
ps. It looks like there is FileUploadHandler.upload_complete(), but I'm
not sure if (and how) I can use it.
No comments:
Post a Comment