assign Document object to FileField

Hi there. I have model with FileField and I have to assign to there Document object (from python-docx library)
I prepared Document object but of course, I couldn’t assign it to FileField - AttributeError Exception appears, because Document object has no attribute ‘_committed’
I thought I can extract from Document object text content and assign ContentFile(“extracted_content”) to FileField in save() method of model, but the problem is that content is extracted in unstructured form, because there are some tables in content. Is there any alternative approaches to save DOcument object to FileField ?

A FileField is not just the content of some data. It’s an object containing a reference to the file on the file system.

The proper way to handle this is to save your file somewhere in your ‘media’ path and then create the FileField object appropriately.

Review the complete Managing Files docs (including the examples) to get some ideas on the ways to do this.

If you need more direct assistance, please post the code in which this work is being done. It’s a lot easier to talk about this in the context of what you’re working with.