django 设置媒体url_没有找到Django媒体URL

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.*)$

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.

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值