我的CSS文件没有加载到Django但Bootstrap文件加载正常

时间:2021-10-02 19:56:49

I have a simple website running on Django. When I load Bootstrap css files, the page loads the formatting just fine. But I try to load the css file I have created and saved in the same folder as the Bootstrap css files, the file does not load. See the file here http://jsfiddle.net/zptkvx5c/ In both case I am making reference to the file in the html head.

我有一个在Django上运行的简单网站。当我加载Bootstrap css文件时,页面加载格式就好了。但我尝试加载我创建的css文件并保存在与Bootstrap css文件相同的文件夹中,该文件无法加载。请参阅此处的文件http://jsfiddle.net/zptkvx5c/在这两种情况下我都在引用html头文件。

<link href="{% static "css/mystyles.css" %}" rel="stylesheet"> 
<!--  <link href="{% static "css/bootstrap.css" %}" rel="stylesheet">  --> This one works    

Could anyone assist to fix this?

谁能协助解决这个问题?

Update: I have tried to hardcode the url and still it doesn't work

更新:我试图硬编码网址,但它仍然无法正常工作

1 个解决方案

#1


1  

you can do this one:

你可以做到这一点:

<link href="css/mystyles.css" rel="stylesheet" /> 

or

要么

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

This one works

这个有效

SEE THE PAGE

看看页面

#1


1  

you can do this one:

你可以做到这一点:

<link href="css/mystyles.css" rel="stylesheet" /> 

or

要么

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

This one works

这个有效

SEE THE PAGE

看看页面