与django无法正常工作的Bootstrap内联日期选择器

时间:2015-03-14 14:21:03

标签: html django twitter-bootstrap datepicker inline

我是这个的新手,但是我正在尝试使用引导日期选择器内联模式,但是我的div在呈现时没有显示任何内容。也许你可能知道我的代码出了什么问题?

<html>
    <head>
        <title>bootstrap datepicker examples</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href={%static "bootstrap-3.3.2-dist/css/bootstrap.min.css" %}>
        <link rel="stylesheet"  type="text/css" href="{%static 'css/datepicker.css' %}"/>
        <link rel="stylesheet" type="text/css" href={%static "css/main.css"%}>
    </head>
    <body>
        <div id="main">
            <div class="datepicker"></div>
        </div>


        <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>  {# jQuery #}
        <script src="{% static 'bootstrap-3.3.2-dist/js/bootstrap.min.js' %}"></script>     {# Bootstrap #}
        <script type="text/javascript" src="{% static 'js/bootstrap-datepicker.js' %}"></script>
        <script>
            $(document).ready(function() {
                $(".datepicker").datepicker();
            });
        </script>

    </body>
</html>

如果我使用标签但是它不在内联模式下,它可以工作。

1 个答案:

答案 0 :(得分:0)

将以下代码放在模板文件的第一行。

{% load staticfiles %}

并更改

<div class="datepicker"></div>

<input class="datepicker" />