Answer the question
In order to leave comments, you need to log in
How to save a file in a model field if the file is already in a Django project?
After creating the file with the python-docx library, I want to save it to the model object.
document.save('isaus/files/media/documents/'+my_doc_name + '.doc')
f = open('isaus/files/media/documents/'+my_doc_name + '.doc', 'rb')
today = datetime.now().date()
mydoc = Document(name=f.name, file=f, data=today)
mydoc.save()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question