Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python不加载CSS_Python_Html_Css_Django - Fatal编程技术网

Python不加载CSS

Python不加载CSS,python,html,css,django,Python,Html,Css,Django,好的,我是Python新手,我在这里使用Django 我无法让Python看到CSS文件并使用它。我尝试过硬编码路径,服务器重新启动,没有任何效果。我可以让它读一个引导CDN,但是,我不知道是什么错了 我的文件结构如下: -migrations -static --music ---images ---style.css (the file that i'm trying to get) -templates --music ---index.html (where my link attr

好的,我是Python新手,我在这里使用Django

我无法让Python看到CSS文件并使用它。我尝试过硬编码路径,服务器重新启动,没有任何效果。我可以让它读一个引导CDN,但是,我不知道是什么错了

我的文件结构如下:

-migrations

-static
--music
---images
---style.css (the file that i'm trying to get)

-templates
--music
---index.html (where my link attribute is)
我尝试在index.html中加载静态CSS文件,如下所示:

{% load staticfiles %}
<link rel="stylesheet" type="text/css" href= "{% static 'music/style.css' %}"/>

提前谢谢

在setting.py文件中添加以下代码

STATIC_ROOT = os.path.join(BASE_DIR,"deploy_to_server")
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)
并在模板中使用

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

希望这能帮助您在setting.py文件中添加以下代码

STATIC_ROOT = os.path.join(BASE_DIR,"deploy_to_server")
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)
并在模板中使用

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

希望这能帮助您

尝试加载static,确保您的static\u root var正在剪切到staticfolder@MauricioCortazar我不确定什么是静态根?但是我尝试了{%load static%},但什么也没有发生。阅读有关static@MauricioCortazar的更多信息好的,我将根指向静态文件,但是没有任何更改。尝试load static,确保您的static_root var正在剪切到静态文件folder@MauricioCortazar我不确定什么是静态根?但是我尝试了{%load static%},但什么也没有发生。阅读更多关于static@MauricioCortazar的信息,好的,我将根指向静态文件,但是没有任何改变。这很有效,我还发现Chrome正在缓存Style.css,所以即使在我得到它“工作”后Chrome也没有显示它。这很有效,我还发现Chrome正在缓存Style.css,所以即使在我得到它“工作”后,Chrome也没有显示它。