Created
August 9, 2011 10:41
-
-
Save philippbosch/1133738 to your computer and use it in GitHub Desktop.
Saving raw POST data to a file field in Django
This file contains 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 | |
uploaded_file = ContentFile(request.raw_post_data) | |
uploaded_file.name = "filename.txt" | |
my_object.file = uploaded_file | |
my_object.save() |
I would've saved quite a bit of time if I had come across this earlier. I had to upload an in-memory generated pdf. Thanks a lot.
Thanks. This helped me a lot.
It doesn't work!
its not working.
@pomponchik thanks so much for the constructive and helpful comment.
Works great. Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks ;)
My ContentFile wasn't saved because I didn't set it's name. Django should have better doc...