django网站中二级目录下的网页打开后没有CSS样式


不是admin后台的样式(这个网上有解决问题)。
而是这样比如:abc.com/blog/create或abc.com/news/add这样在create和add页面中没有css样式,我觉得是urls.py的问题,但不知具体怎么错了,代码如下,有一个主目录urls.py,另外两个是blog和news应用下的urls.py文件


 // 主目录的urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.auth.views import login,logout     
urlpatterns = patterns('',
    # Examples:
    url(r'^blog/', include('blog.urls')),
    url(r'^news/',include('news.urls')),
)

//news/urls.py
from django.conf.urls import patterns, include, url

urlpatterns = patterns('news.views',
    url(r'^$','news_list'),
    url(r'add/$','add_news'),
)

//blog/urls.py
from django.conf.urls import patterns, include, url
from blog.views import create_topic

urlpatterns = patterns('blog.views',
    url(r'^$','topic_list'),
    url(r'^create/$','create_topic'),
)

python django css

菊花爱好者 10 years, 3 months ago

{% static 'css/bootstrap.css' %} 你看看这个标签到了html里面是什么url,如果这个能写对也是可以的啊。

是东方时代 answered 10 years, 3 months ago

sb了,我再base.html调用静态css时用的是直接的路径(“../static/css/bootstrap.css”),改成了({% static 'css/bootstrap.css' %})就可以了,谢谢评论问题的各位。

红脖子微笑动画 answered 10 years, 3 months ago

Your Answer