报错:
Not Found: /test/static/plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css
[05/Apr/2024 00:35:27] "GET /test/static/plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css HTTP/1.1" 404 2849
只有在views中增加了一个参数才会复现出报错,如:
def test(request, nid):
return render(request, 'test.html')
原因:母版文件bootstrap的css文件引用失败,
一开始写成了
<link rel="stylesheet" href="../static/plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css">
正确写法为:
<link rel="stylesheet" href="{% static 'plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css' %}">