0

我是 Django 新手,第一次阅读Django Book。我尝试将一些引导的 html 放入文件中:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Test</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link href="assets/css/bootstrap.css" rel="stylesheet">
    <link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/js/google-code-prettify/prettify.css" rel="stylesheet">

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="assets/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
</head>
<body>
    <header><a href="index.html" title="Home"><img src="assets/img/logo.png" alt="Test" /></a></header>
    <div class="container" style="text-align:center;">
        <br /><br />
        <form class="search form-inline" action="searchresults.html">
            <div class="input-append">
                <input class="search-input input-xxlarge" id="appendedPrependedInput" size="16" type="text" placeholder="Type in your search"><button class="btn btn-large btn-danger" type="submit">Search</button>
                </div>
            <!--<input type="text" class="search-input input-xlarge" placeholder="Type in your search">
            <button type="submit" class="btn btn-large btn-danger">Search</button> -->
        </form>

        <hr class="soften">

    </div>
</body>
</html>

并用这个视图渲染它:

def search(request):
    return render_to_response('search_page.html')

当我使用启动测试服务器时,python manage.py runserver我得到一个简单丑陋的 html 页面,而不是引导页面。为什么是这样?(我确实在同一目录中有引导资产)

4

2 回答 2

1

您的静态文件可能没有正确设置。转到“查看源代码”并单击 CSS 文件并查看是否收到 404。

以下是设置静态文件目录的方法:http: //docs.djangoproject.com/en/dev/howto/static-files

于 2012-05-05T00:23:45.723 回答
1

我还建议查看django-bootstrap-toolkit

于 2012-05-07T13:39:40.063 回答