4

I'm running into a strange issue,hope some where else some one can had faced the same problem.My problem which is like, the stored media in django application are not able to serve through MEDIA_ROOT URL.When I tried to get list of media files that are saved in my application using URL myhost/media/ it showing all the media files.But when I tried to view on of them using URL myhost/media/image.jpg, got error Requested page not found.

Error Track Trace:

Using the URLconf defined in myapp.urls, Django tried these URL patterns, in this order:

1.^media\/(?P<path>.*)$

The current URL, ~myapp/media/image.jpg, didn't match any of these.

My app settings.py

MEDIA_ROOT = '/home/itsme/myapp/media/'
MEDIA_URL = '/media/'
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
     'django.template.loaders.eggs.Loader',
)

Urls.py

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',

) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Can any one suggest me solution for this.

Thanks.

10
  • Maybe, try this: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') If you're using Django > 1.5 Commented Apr 27, 2014 at 8:37
  • does that mean the problem is resolved? Commented Apr 27, 2014 at 9:54
  • @skzryzg No,problem is not resolved. Commented Apr 27, 2014 at 9:58
  • could you post your entire urls.py? Commented Apr 27, 2014 at 9:59
  • @Ramakrishna, "Not persisted" means the problem is no longer there. Commented Apr 27, 2014 at 10:00

1 Answer 1

2

After so many trails,finally I have fixed the issue.The problem is related to permission of media files.The process that's trying to access these media files is root and the files are owned by the user itsme. There's a kernel patch that prevents these type of accesses.So why 404 error is returning as response.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.