How to assign a local file to the FileField in Django?

Django uses it’s own file type (with a sightly enhanced functionality). Anyway Django’s file type works like a decorator, so you can simply wrap it around existing file objects to meet the needs of the Django API. from django.core.files import File local_file = open(‘mytest.pdf’) djangofile = File(local_file) pdfImage.myfile.save(‘new’, djangofile) local_file.close() You can of course decorate … Read more