美文网首页
Django找不到static静态资源文件

Django找不到static静态资源文件

作者: YangDxg | 来源:发表于2018-06-06 17:46 被阅读0次

    为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')
    

    相关文章

      网友评论

          本文标题:Django找不到static静态资源文件

          本文链接:https://www.haomeiwen.com/subject/srcisftx.html