Created
April 24, 2016 12:56
-
-
Save mazlum/ffe7c00cfad4a2c65f8d4b1b14bfc7f2 to your computer and use it in GitHub Desktop.
Django Create File Model from base64 data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.files.base import ContentFile | |
| #... | |
| base64_data = "" | |
| model_file = ContentFile(base64.b64decode(base64_data), "filename") | |
| ModelObject.objects.create(file_field=model_file) | |
| #... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment