Django本地引用bootstrap,在IE浏览器正常引用,在chrome浏览器无法正常引用?

在 Django 本地引用 bootstrap 时,发现在 IE 浏览器正常引用,在 chrome 中未能正常引用。CDN 方式引用都显示正常。

这是 settings.py 的设置:

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]

这是 base.html:

<!--base.html-->
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>
        {% block title %} {% endblock %}
    </title>

<link  href="/static/css/bootstrap.min.css" rel="stylesheet">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
{#<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">#}
{#<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>#}
{#<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>#}
</head>
<body>

<div class="container-fluid">
    {% include 'header.html' %}
    <div class="{panel panel-default">
        <div class="panel panel-heading">
            {% block headmessage %} {% endblock %}
        </div>
        <div class="panel panel-body">
            {% block content %}{% endblock %}
        </div>
        <div class="panel panel-footer">
            {% include 'footer.html' %}
        </div>
    </div>
</div>

</body>
</html>

这是其中一个 index.html 内容

<!--index.html-->

{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}
欢迎光临我的博客
{% endblock %}
{% block headmessage %}
<h3 style="font-family: 楷体;">本站文章列表</h3>
{% endblock %}
{% block content %}
    {% for post in posts %}
        <p style="font-family: 微软雅黑;font-size: 14pt;font-weight: bold;">
            <a href="/post/{{ post.slug }}">{{ post.title }}</a>
        </p>
    {% endfor %}
{% endblock %}

这是项目列表:

图片描述

chrome中显示:

图片描述

IE显示:

图片描述

阅读 4k
1 个回答

你在浏览器调试一下试试,我之前用的时候没出想过这种情况。有可能是你static路径配置的问题。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题