24👍
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.
27👍
I was getting the same error and fix it by changing:
MEDIA_ROOT = '/media/'
to:
MEDIA_ROOT = 'media/'
Under settings.py
.
- Django- getting a list of foreign key objects
- How does one use a custom widget with a generic UpdateView without having to redefine the entire form?
2👍
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/
- Django queryset order_by dates near today
- How do I restrict access to admin pages in Django?
- Display query string values in django templates
- How to serve Django for an Electron app
1👍
For me, I forgot to add: MEDIA_ROOT = os.path.join(BASE_DIR,’media’) to my settings.py file on my production server.
- Django database delete specific number of entries
- Django form dropdown list of stored models
- Nullable TextField or empty string in Django model?
0👍
Thanks to https://stackoverflow.com/users/10949995/clement-tong for the inspiration. I experienced the same error in a production environment and I had to change settings.py file to include a preceding forward slash:
MEDIA_ROOT = os.path.join(BASE_DIR, "/media")
- Django formset not validating because ID is required
- How to get Interdependent dropdowns in django using Modelform and jquery?
- How does Django serve media files?
0👍
I was getting the same error and fix it by doing the following in setting.py file of the project:
MEDIA_ROOT = '/media/'
to
MEDIA_ROOT = 'media/'
- Django form dropdown list of stored models
- How do I memoize expensive calculations on Django model objects?
- How can my Model primary key start with a specific number?
- Determine if an attribute is a `DeferredAttribute` in django
- Django.core.exceptions.ImproperlyConfigured