Django: How to save InMemoryUploadedFile (a temporary uploaded file) to disk?

When a user uploads a file using forms.FileField, you usually want to save it in some way.

To stash the file away on disk, just use the following snippet.

from import default_storage
from django.core.files.base import ContentFile

file = request.FILES['your_file_fieldname']
path ='heart_of_the_swarm.txt', ContentFile(

There you have it!


Now back to more important things, like eating cheerleaders.


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog