Tuesday, August 28, 2012

Re: Problem serving files from media directory

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

On Tue, Aug 28, 2012 at 1:40 AM, neridaj <neridaj@gmail.com> wrote:
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

--
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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment