我正在尝试让 django-autocomplete-light 在我的应用程序中工作。我想我已经完成了所有设置。
似乎是问题的一件事是,当我包含:{% include 'autocomplete_light/static.html' %}。我认为我的应用程序没有找到下面列出的必要 .js 文件。当我转到目录时,我看不到文件。我认为 github 下载应该包含这些文件。我应该在哪里下载这些 js 文件?或者可能是目录结构不正确?
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/autocomplete.js HTTP/1.1" 404 1715
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/django_admin.js HTTP/1.1" 404 1715
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/text_widget.js HTTP/1.1" 404 1712
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/widget.js HTTP/1.1" 404 1697
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/style.css HTTP/1.1" 404 1697
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/addanother.js HTTP/1.1" 404 1709
[21/Nov/2015 10:59:30] "GET /static/autocomplete_light/remote.js HTTP/1.1" 404 1697
html:
{% load staticfiles %}
<script type="text/javascript" src="{% static 'jquery.js' %}">
$(document).ready(function() {
$('#add_user_accounts').InstitutionAutocomplete({
url: '{% url 'add_user_accounts' %}',
choiceSelector: 'a',
}).input.bind('selectChoice', function(e, choice, autocomplete) {
document.location.href = choice.attr('href');
});
});
</script>
{% include 'autocomplete_light/static.html' %}
<input type="text" name="q" id="add_users_accounts" placeholder="Find your institution" style="width: 270px; font-size: 12px;" />
<style type="text/css">
/* cancel out django default for now, or choices are white on white */
#header a.choice:link, #header a.choice:visited {
color: black;
}
</style>
目录结构:
app/
static/jquery.js
autocomplete_light/