I am able to upload the files to media folder( '/peaceroot/www/media/'
) that I have set up in settings.py
as below
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
Add media url entry in your project urlpatterns:
The better way for MEDIA_ROOT is,
try to make media path dynamic will be easy when you shift your project.
Settings.py
urls.py
Look at this
https://docs.djangoproject.com/en/dev/howto/static-files/
Just to add: in case the other answers do not work for you, try putting the static url before the other ones. Like so:
What may be happening is that some of your patterns in the list prevent the request from reaching the static handlers. So putting the static handlers first solves this. Worked for me.