SHARE
TWEET

Untitled

a guest Aug 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.core.files.base import ContentFile
  2. import os
  3.  
  4. source_attachment = source_obj.source_attachment
  5. filecontent = ContentFile(source_attachment.file.read())
  6. filename = os.path.split(source_attachment.file.name)[-1]
  7.  
  8. target_obj.target_attachment.save(filename, filecontent)
  9. target_obj.save()
  10.  
  11. # VERY IMPORTANT !
  12. source_attachment.file.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top