1

我正在使用 Django 和静态媒体应用程序以及 Nginx。由于某种原因,外部样式表不适用。但是,当我在源文件中单击它时,它确实会加载 style.css 文件。

{% load static from staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>Title</title>

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

<!-- EVEN THIS DOESN'T LOAD HERE
<link rel="stylesheet" type="text/css" media="screen" href="/static/css/style.css"  />
-->

</head>
<body>
<!-- some stuff -->
</body>
</html>
4

1 回答 1

0

Check the error log of Nginx (error.log). Sometimes it is on the path '/usr/local/nginx/logs/error.log'.

Load the page and then make in command line: "tail -n 20 /usr/local/nginx/logs/error.log". You can see the path on which Nginx tries to load your css file and error message if there is no such file on the path.

The pass and the name of file are both case-sensetive.

If your css file loads normally (you can see it, for example, by using firebug) then it is not a problem of Django. Definitely there is a mistake in HTML and/or in CSS.

于 2012-07-30T07:09:53.907 回答