Search code examples
djangodjango-modelsdjango-file-upload

Django FileField passing the files


OK, I have a model for TemporaryFile and the final file model (File) they have different storage functions (destinations). I'm saving the first model and after some time I need to pass the file to the second model, so that it saves the file its way. For now I'm doing something like that:

attachments.append(File(file=temp.file.file, message=self))

But it just passes over the URL. Which isn't what I'd like to see.


Solution

  • This questions has been answered here: copy file from one model to another.

    Spoilers: it requires StringIO.