How to save images on the server using Django

  • last month
The saving of files on the server with Django is very simple. We just need to call the default_storage instance of the django.core.files.storage module and use the method save to save the files.

In settings.py we need to specify for MEDIA_ROOT where will be saved the files.
Transcript
00:00To save an image on the server using Django, I first need to handle the incoming URL request.
00:16In my project I have this URL to the media app.
00:26And here I am handling this URL.
00:43In this class I first verify if the ID user is authenticated.
00:55Then I check if the format is supported.
01:04And finally I save the image using this function.
01:13The image is saved in this directory.

Recommended