为python中试图配置css,报错找不到css文件
[06/Jun/2018 09:19:13] "GET /polls/ HTTP/1.1" 200 241
[06/Jun/2018 09:19:13] "GET /static/polls/style.css HTTP/1.1" 404 1669
[06/Jun/2018 09:24:22] "GET /polls/ HTTP/1.1" 200 199
[06/Jun/2018 09:24:22] "GET /static/polls/style.css HTTP/1.1" 404 1669
[06/Jun/2018 09:24:23] "GET /polls/ HTTP/1.1" 200 199
[06/Jun/2018 09:24:23] "GET /static/polls/style.css HTTP/1.1" 404 1669
[06/Jun/2018 09:24:23] "GET /polls/ HTTP/1.1" 200 199
[06/Jun/2018 09:24:23] "GET /static/polls/style.css HTTP/1.1" 404 1669
{% load static %}
<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_text }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
在settings.py中进行如下修改
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
网友评论