django,runserver_plus - 从错误路径提供的管理媒体文件
下面的配置在我的远程主机上运行良好(相同的目录结构,相同的 django),所有管理媒体均正确
设置
MEDIA_ROOT = '%s/static/' % FS_ROOT
STATIC_DOC_ROOT = '%s/static/' % FS_ROOT
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '%smedia/' % MEDIA_URL
urls
(r'^admin/', include(admin.site.urls)),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '%s/static' % FS_ROOT }),
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '%s/media' % FS_ROOT }),
django 1.2.0 @ ubuntu 9.10, http://127.0.0.1:8084/ 通过 runserver_plus
管理媒体文件存储在我的项目根目录中的 /static/media/ 下,每个静态文件/目录存储在 /static/ 下。所有静态服务都很好,只有管理媒体是从默认的 django 管理媒体文件中获取的。我忘记了什么以及为什么它只影响我的本地主机上的项目?我尝试过以各种方式在 url 中使用 /static/media/ 路径,但仍然一无所获。
The configuration below works fine on my remote host (same dir structure, same django), all admin media are served properly
settings
MEDIA_ROOT = '%s/static/' % FS_ROOT
STATIC_DOC_ROOT = '%s/static/' % FS_ROOT
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '%smedia/' % MEDIA_URL
urls
(r'^admin/', include(admin.site.urls)),
(r'^static/(?P<path>.*)
django 1.2.0 @ ubuntu 9.10, http://127.0.0.1:8084/ via runserver_plus
Admin media files are stored under /static/media/ in my project root dir and every static files/dirs under /static/. All statics are served fine, only the admin media are taken from the default django's admin media files. What am I forgetting and why it does affect the project only on my localhost? I've tried to everride /static/media/ path in the urls in various ways, but still nothing.
, 'django.views.static.serve',
{'document_root': '%s/static' % FS_ROOT }),
(r'^media/(?P<path>.*)
django 1.2.0 @ ubuntu 9.10, http://127.0.0.1:8084/ via runserver_plus
Admin media files are stored under /static/media/ in my project root dir and every static files/dirs under /static/. All statics are served fine, only the admin media are taken from the default django's admin media files. What am I forgetting and why it does affect the project only on my localhost? I've tried to everride /static/media/ path in the urls in various ways, but still nothing.
, 'django.views.static.serve',
{'document_root': '%s/media' % FS_ROOT }),
django 1.2.0 @ ubuntu 9.10, http://127.0.0.1:8084/ via runserver_plus
Admin media files are stored under /static/media/ in my project root dir and every static files/dirs under /static/. All statics are served fine, only the admin media are taken from the default django's admin media files. What am I forgetting and why it does affect the project only on my localhost? I've tried to everride /static/media/ path in the urls in various ways, but still nothing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种解决方案:
There are two solutions: