如果使用媒体?

2 views
Skip to first unread message

ne.manman

unread,
Aug 17, 2006, 10:42:29 AM8/17/06
to django-cn
比如我的web主目录里有个图片目录: /images ,
现在我要在templates/c.html里使用/images里的一个图片a.gif

请问该如何设置 setting.py里的MEDIA_ROOT 和 MEDIA_URL ,
在c.html里又该如何书写此图片的路径呢?

不是在apache环境里

憨狗

unread,
Aug 19, 2006, 12:05:57 AM8/19/06
to djan...@googlegroups.com

可以参考,木头兄写的:
http://www.woodpecker.org.cn/obp/django/django-stepbystep/newtest/doc/tut09.html

http://www.woodpecker.org.cn/obp/django/django-stepbystep/newtest/doc/tut12.html
里面都有提到如何设定这些路径。
如果要深究的话,可以看看:
django.views.static.serve
的代码。
因为提供这些文件(图片、css等静态内容)的时候都是使用的django.views.static.serve来处理的。
即在urls中做类似于如下的设置:

(r'^image/(?P<path>.*)$', 'django.views.static.serve')

--
初从文,三年不中; 后习武,校场发一矢,中鼓吏,逐之出; 遂学医,有所成。 自撰一良方,服之,卒
个人blog: http://hackgou.itbbq.com
Email/Skype/MSN/QQ/Gtalk : HackGou#Gmail.com
PGP KeyID: hackgou AT Gmail.com
PGP KeyServ: subkeys.pgp.net

Reply all
Reply to author
Forward
0 new messages