Django - Media upload [Errno 13] Permission denied
The process that is running your Python interpreter doesn't have permission to write into the media directory. You'll need to either chgrp
or chown
the media directory to the same group as your Python process, and ensure you have at least g+rwx
on directories and g+rw
on files.
For me, I forgot to add: MEDIA_ROOT = os.path.join(BASE_DIR,'media') to my settings.py file on my production server.
Make sure you have done following
Your settings.py
...
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
...
Also set permission to media directory
chgrp -R www-data /path/to/media/
chmod -R g+w /path/to/media/
I was getting the same error and fix it by changing:
MEDIA_ROOT = '/media/'
to:
MEDIA_ROOT = 'media/'
Under settings.py
.