Django 1.3 - 简单的媒体部署
我在让 django 与我的媒体设置良好配合时遇到了一些真正的困难。我没有使用静态文件,因为在项目的这个阶段我不需要 CDN,并且我想保持简单。
我的文件夹结构如下所示:
/static
/admin
/css
/js
/etc
/css
/js
/images
admin 文件夹是 admin contrib 媒体文件夹的副本...因为我使用的是 mod_wsgi 我知道它不能存在于 django 项目文件夹中。
我的设置文件:
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static/')
MEDIA_URL = 'http://127.0.0.1:8000/static/'
ADMIN_MEDIA_PREFIX = 'admin/' (tried with leading slash too)
URL:
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root':MEDIA_ROOT, 'show_indexes':True}),
无论我尝试什么,我都无法让管理媒体提供服务。通过阅读文档我知道 ADMIN_MEDIA_PREFIX 必须与普通媒体 url 非常不同,但由于 mod_wsgi,我需要能够在系统 django 文件夹之外提供文件。
有人可以帮忙吗?
I having some real trouble getting django to play nice with my media setup. I am not using staticfiles since I am have no need for a CDN at this point of the project and I want to keep it simple.
My folder structure looks like this:
/static
/admin
/css
/js
/etc
/css
/js
/images
The admin folder is a copy of the admin contrib media folder... since I am using mod_wsgi I know that this can't live in the django project folder.
My settings file:
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static/')
MEDIA_URL = 'http://127.0.0.1:8000/static/'
ADMIN_MEDIA_PREFIX = 'admin/' (tried with leading slash too)
Urls:
(r'^static/(?P<path>.*)
No matter what I try, I can't get the admin media to serve. I know from reading the documentation that the ADMIN_MEDIA_PREFIX has to be very different from the normal media url, but I need to be able to serve the files outside of the system django folder because of mod_wsgi.
Can anyone help?
, 'django.views.static.serve', {'document_root':MEDIA_ROOT, 'show_indexes':True}),
No matter what I try, I can't get the admin media to serve. I know from reading the documentation that the ADMIN_MEDIA_PREFIX has to be very different from the normal media url, but I need to be able to serve the files outside of the system django folder because of mod_wsgi.
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您的设置,
ADMIN_MEDIA_PREFIX = MEDIA_URL + 'admin/'
应该有效。For your setup,
ADMIN_MEDIA_PREFIX = MEDIA_URL + 'admin/'
should work.