【发布时间】:2016-02-08 19:20:16
【问题描述】:
我是 Django 新手,在 django 页面上呈现引导程序时遇到问题。
这是我的基本 html,
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Dropbox Web App Prototype</title>
<!-- Bootstrap -->
<link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>This is a template showcasing the optional theme stylesheet included in Bootstrap. Use it as a starting point to create something more unique by building on or modifying it.</p>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
</body>
</html>
我还在我的 settings.py 文件中添加了以下行
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
CSS 未在主页上呈现。任何帮助表示赞赏。
【问题讨论】:
-
你使用哪个 Django 版本?
-
静态文件应在您的项目文件夹下(即与 urls.py 和 settings.py 位于同一文件夹),并确保您的应用已添加到您的 settings.py INSTALLED_APPS 列表中
-
@pp_ 1.9.2 是版本
-
@JoranBeasley 它就在那里,我已将应用添加到已安装应用列表中。
标签: python css django twitter-bootstrap