我在本地主机上运行,但样式表不工作
这是我的项目设置:
-main
-main
-home
-templates
-home
-index.html
-static
-css
-style.css
我的设置.py:
STATICFILES_DIRS = [
"/static/",
]
STATIC_URL = '/static/'
index.html:
{% load staticfiles %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>My Home Page</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}" />
</head>
<body>
<p>My Content</p>
</body>
</html>
这是我的服务器输出的内容:"GET/static/css/style.css HTTP/1.1"404 1652
怎么了?
请您参考如下方法:
好吧,这个改变似乎解决了它:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
'/static/',
]
