我的django_select2字段只是管理员中的正常选择

时间:2014-03-27 11:02:58

标签: django jquery-select2

我试图将Select2字段添加到我的管理网站,但它固执地仍然是一个基本的选择字段......

已安装的软件:django 1.6,django_select2 4.4

forms.py:

add_members_of = django_select2.fields.ModelSelect2MultipleField(
    label='Add another group\'s members',
    queryset=models.DomainGroup.objects.all(),
    required=False
)

HTML页面标题(选定位):

<link href="/static/css/select2.css" type="text/css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="/static/admin/js/jquery.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
<script type="text/javascript" src="/static/admin/js/SelectBox.js"></script>
<script type="text/javascript" src="/static/admin/js/SelectFilter2.js"></script>
<script type="text/javascript" src="/static/js/select2.js"></script>

页面中的相关位:

<div class="form-row field-add_members_of">
    <div>
    <label for="id_add_members_of">Add another group&#39;s members:</label>
    <select multiple="multiple" id="id_add_members_of" name="add_members_of">
    <option value="Backup Operators">Backup Operators</option>
    ...
    <option value="vpnusers">vpnusers</option>
    </select>
    <script type="text/javascript">
        jQuery(function ($) {
            $("#id_add_members_of").select2({'closeOnSelect': false, 'placeholder': ''});
        });
    </script>
    <p class="help"> Hold down "Control", or "Command" on a Mac, to select more than one.</p>
    </div>
</div>

服务器清楚地发送js和css:

[27/Mar/2014 11:59:41] "GET /static/css/select2.css HTTP/1.1" 200 19222
[27/Mar/2014 11:59:41] "GET /static/js/select2.js HTTP/1.1" 200 134009

任何人都知道我做错了什么?

0 个答案:

没有答案