Skip to content
Advertisement

Converting bytes to file in Django / Python

In my Django app, I have a PDF in bytes:

JavaScript

I want to save it in my database:

JavaScript

However I keep getting an 'bytes' object has no attribute '_committed' error on save.

Advertisement

Answer

The answer was a built-in Django function, ContentFile.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement