Problem serving files from media directory

22 views
Skip to first unread message

neridaj

unread,
Aug 27, 2012, 6:40:03 PM8/27/12
to django...@googlegroups.com
Hello,

I've deployed a new website to my staging and production servers but for some reason the images in the media directory are displaying 404 errors. The path to the image is correct and the image is located at that path:

<img src="/media/projects/hair/2012/test-1/13221803.jpg" alt="Slide 1" width="570" height="270" style="">

ls -la ~/.virtualenvs/website/project/media/projects/hair/2012/test-1
total 144
drwxr-x--- 2 username username   4096 Aug 27 16:43 .
drwxr-x--- 3 username username   4096 Aug 27 16:43 ..
-rwxrwxr-x 1 username username 131719 Aug 27 16:43 13221803.jpg

settings.py:

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'

Am I having problems because the image file is nested within other directories? Files are being served from the static directory just fine, any ideas?

Thanks,

Jason

Joseph Mutumi

unread,
Aug 28, 2012, 5:56:30 AM8/28/12
to django...@googlegroups.com
Hi, Django isn't responsible for serving any kind of static files in production.
It is not a web server ! You need to configure the web server you are using
to serve the files in that folder.

The documentation has a good example conf for Apache:
https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/#serving-files

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Kk3KOw-L4RQJ.

To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages