I ran into some strange problem, I hope that somewhere else someone might run into the same problem. My problem is that the storage media in the django application cannot serve the URL MEDIA_ROOT. When I tried to get a list of the media files that were saved in my application using the myhost / media / url showing all the media files. But when I tried to view them using the URL myhost / media / image.jpg, an error occurred. The requested page was not found.
Error Tracking Track:
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 application 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 anyone suggest me a solution for this.
Thank.
source
share