无法在Django模板

时间:2016-07-02 14:06:05

标签: python html css django

这是我简化的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

1 个答案:

答案 0 :(得分:3)

更改

<link href="{% static '/css/buttonform.css' %}" rel="stylesheet">

<link href="{% static 'css/buttonform.css' %}" rel="stylesheet">