I am able to upload the files to media folder( '/peaceroot/www/media/') that I have set up in settings.py as below
'/peaceroot/www/media/'
settings.py
MEDIA_ROOT = '/peaceroot/www/media/' MEDIA_URL = '/media/'
But through admin I tried to access the uploaded image file
http://localhost:8000/media/items/1a39246c-4160-4cb2-a842-12a1ffd72b3b.jpg
then I am getting 404 error.
The file exists at peaceroot/www/media/items/1a39246c-4160-4cb2-a842-12a1ffd72b3b.jpg
peaceroot/www/media/items/1a39246c-4160-4cb2-a842-12a1ffd72b3b.jpg
Add media url entry in your project urlpatterns:
from django.conf.urls.static import static from django.conf import settings ... urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1.4m articles
1.4m replys
5 comments
57.0k users