Python django中的style.css文件位置

Python django中的style.css文件位置,python,html,css,django,Python,Html,Css,Django,我有一个style.css文件,它在Django项目中的所有应用程序中都是通用的。其位置如下: testsite______ | | testsite | | news | | reviews | |

我有一个style.css文件,它在Django项目中的所有应用程序中都是通用的。其位置如下:

testsite______
              |
              |
           testsite
              |
              |
             news 
              |
              |
            reviews
              |
              |
           templates------>static------>css------> style.css
              |
              |
           manage.py
STATIC_URL = '/static/'
STATICFILES_DIRS = (
        "/path/to/my/project/templates/static/",
)
<html>
    <head>
        <title>TEst site</title>
        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css"/>
    </head>
"GET /test-site/css/style.css HTTP/1.1" 404 4147
在项目的settings.py中,我有如下
静态文件\u DIRS

testsite______
              |
              |
           testsite
              |
              |
             news 
              |
              |
            reviews
              |
              |
           templates------>static------>css------> style.css
              |
              |
           manage.py
STATIC_URL = '/static/'
STATICFILES_DIRS = (
        "/path/to/my/project/templates/static/",
)
<html>
    <head>
        <title>TEst site</title>
        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css"/>
    </head>
"GET /test-site/css/style.css HTTP/1.1" 404 4147
我调用模板标题中的css文件,如下所示:

testsite______
              |
              |
           testsite
              |
              |
             news 
              |
              |
            reviews
              |
              |
           templates------>static------>css------> style.css
              |
              |
           manage.py
STATIC_URL = '/static/'
STATICFILES_DIRS = (
        "/path/to/my/project/templates/static/",
)
<html>
    <head>
        <title>TEst site</title>
        <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css"/>
    </head>
"GET /test-site/css/style.css HTTP/1.1" 404 4147

我是否需要在URL.py中为css指定一些内容?我在这里遗漏了什么?

不,您不必在URL中指定任何css。 尝试将其放入HTML中

{% load staticfiles %}
打个电话

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


我这样做,效果很好。

安装的应用程序中是否有
django.contrib.staticfile
@karthikr-是的,
django.contrib.staticfile
位于
INSTALLED\u APPS