Possible Duplicate:
Django and Serving Static Files
我有一个问题要加载CSS基本.html. 我把所有css文件放在/static目录下。在
在urls.py
我写了以下代码:
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{ 'document_root': '/home/bkcherry/botstore/botstore/static' }),
)
在基本.html我提出以下几点:
^{pr2}$当我去主.html,css样式不起作用。我需要配置设置.pyMEDIA_ROOT
、MEDIA_URL
还是{
我想你需要在路径的末尾加一个斜线,即
'/home/bkcherry/botstore/botstore/static/'
如果你检查官方文件
媒体根目录末尾应该有/(https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-MEDIA_ROOT)
您必须不使用媒体根目录或媒体URL这是用于上载的媒体而不是静态内容,并且您不需要设置URL模式,因为这仅适用于django 1.2或“如果您正在使用其他服务器进行本地开发”:https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development
您需要将静态文件保存在: 机器人商店/机器人商店/静态/机器人商店/css.css在
然后使用:
然后在HTML中可以引用静态文件,从而:
^{pr2}$相关问题 更多 >
编程相关推荐