开始照着Django的教程做的应用,没有用到css和js,没有讲到这个问题。所以在实际用到css和js时,才发现这个问题,我发现最方便的方法是在应用的urls.py的映射当中,增加这两行:
(r’^css/(?P<path>.*)$’, ‘django.views.static.serve’,{‘document_root’: ‘F:/rocksun/rstools/template/css’}),
(r’^images/(?P<path>.*)$’, ‘django.views.static.serve’,{‘document_root’: ‘F:/rocksun/rstools/template/images’}),
这样设置之后,模板中对于/css的请求就会进入我设置的F:/rocksun/rstools/template/css目录下,同理images,不需要设置media目录了。
Related posts:
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.