这是我简化的html代码:
{% load staticfiles %}
<html lang="en">
<head>
<link href="{% static '/css/buttonform.css' %}" rel="stylesheet">
</head>
</html>
这是我的 settings.py :
INSTALLED_APPS = ['django.contrib.staticfiles',]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "static_root")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static_in_pro", "our_static"),
)
css文件存在于STATICFILES_DIRS中,但错误如下:Not Found: /css/buttonform.css
答案 0 :(得分:3)
更改
<link href="{% static '/css/buttonform.css' %}" rel="stylesheet">
到
<link href="{% static 'css/buttonform.css' %}" rel="stylesheet">