media路径设置:
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/'
网页中图片无法显示,显示404错误:
[28/Oct/2014 11:03:15] "GET /media/photos/44.thumb.JPG HTTP/1.1" 404 2528
解决方法:
根据DJANGO1.6文档 -6.19.2 static():
设置项目URL文件:
from django.conf import settings from django.conf.urls.static import static urlpatterns = patterns(’’, # ... the rest of your URLconf goes here ... ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
结果显示正常:
"GET /media/photos/44.thumb.JPG HTTP/1.1" 200 1956
注:仅适用于开发服务器。