简体   繁体   English

Django不显示我模板的CSS

[英]Django doesn't show the CSS of my template

The problem is described in title. 问题在标题中描述。 I have this template for a blog that I'm creating using Django . 我有使用Django创建的博客的模板。

When I open it normally, using double click over the HTML file, it looks like this: 当我正常打开它时,双击HTML文件,它看起来像这样:

模板工作

But when I open it via url from the Django project, it looks like this 但是当我通过Django项目中的url打开它时,它看起来像这样

模板不起作用

It only shows a green square (part of the css) but obviously can't open the css correctly. 它仅显示一个绿色方块(css的一部分),但显然无法正确打开css。

Any idea to solve this? 有解决的办法吗?

In Django you don't open the HTML with double click on the file, you need to run the server first and open your site using the localhost (like you did in the second picture). 在Django中,您无需双击该文件即可打开HTML,您需要先运行服务器,然后使用localhost打开站点(如第二张图片所示)。

Judging by those images, are you sure you put the image in the static folder? 从这些图像来看,您确定将图像放在静态文件夹中吗? In Django, the HTML files stays in the "templates" folder of your app and the css, javascript and images in the "static" folder. 在Django中,HTML文件保留在应用程序的“模板”文件夹中,而CSS,JavaScript和图像保留在“静态”文件夹中。

If this answer doesn't help you, then you should post your code here, otherwise I can't find the problem. 如果此答案对您没有帮助,则应在此处发布代码,否则我找不到问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM