Reputation: 14022
I have a file located at below relative path in my source code:
docs/Shootsta_Videographer_critical_info.pdf
I want to convert this file into a Django File object. Please help.
Upvotes: 0
Views: 419
Reputation: 677
The docs for Django https://docs.djangoproject.com/en/2.2/ref/files/file/ states that the File constructor accept a Python file object.
So something like this:
from django.core.files import File
django_file = File(open('<base_dir>/docs/Shootsta_Videographer_critical_info.pdf'))
Upvotes: 1