首先,我意识到Django 1.8已经过时了,但我必须为一个项目学习它。我完成了前五个部分,没有任何问题,但是当我尝试链接第6部分中的样式表时,我的样式表没有加载(页面没有变化)。
我已经检查了代码几次,并检查了每个文件夹的名称空间,它应该可以工作,但我似乎找不到问题。如果有人读过这篇教程,并能对这个问题有所了解,我将不胜感激。
下面是mysite/polls/templates/polls/index.html中的代码:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css'
%}" />
{% if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li><a href="{% url 'polls:detail' question.id %}">{{
question.question_t\
ext }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}下面是我的样式表,位于mysite/polls/static/polls/style.css:
li a {
color: green;
}
body {
background: white url("images/background.gif") no-repeat right
bottom;
}发布于 2018-06-22 14:04:27
对于任何有同样问题的人,重新启动Django服务器解决了这个问题。
https://stackoverflow.com/questions/50980539
复制相似问题