django-autocomplete-light无法找到.js脚本

时间:2022-03-18 01:40:00

I am trying to get django-autocomplete-light to work in my app. I think I have gotten everything setup.

我想让django-autocomplete-light在我的应用程序中工作。我想我已经完成了所有设置。

One thing that seems to be the problem is that when I include: {% include 'autocomplete_light/static.html' %}. I think my app isn't finding the necessary .js files listed below. When I go to the directory, I don't see the files. I thought the github download should include these files. Where should I be downloading these js files? or may be directory strucuture is incorrect?

似乎问题的一点是,当我包括:{%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>

Directory structure:

app/
    static/jquery.js
autocomplete_light/

1 个解决方案

#1


0  

I was having the same 404 error. It was resolved after i reinstalled the django-autocomplete-light properly.

我有同样的404错误。我正确地重新安装了django-autocomplete-light后解决了问题。

For my case it was because i installed the package that i downloaded in zip format and extracted into a local directory:

对于我的情况,这是因为我安装了我以zip格式下载并解压缩到本地目录的软件包:

pip install -e path_to_downloaded_package_extracted

Obviously some files were not copied or some links were not created properly.

显然,某些文件未被复制或某些链接未正确创建。

Then i started a new virtual env and gave a try to tar.gz format as follows:

然后我开始了一个新的虚拟环境并尝试了tar.gz格式,如下所示:

pip install --no-index -f ~/path_to_local_cache django-autocomplete-light

Than it worked. All the files were up and running. Note that you must have all the required packages downloaded into the same directory for pip to deal with dependency chain.

比它工作。所有文件都已启动并正在运行。请注意,必须将所有必需的包下载到pip的同一目录中才能处理依赖关系链。

#1


0  

I was having the same 404 error. It was resolved after i reinstalled the django-autocomplete-light properly.

我有同样的404错误。我正确地重新安装了django-autocomplete-light后解决了问题。

For my case it was because i installed the package that i downloaded in zip format and extracted into a local directory:

对于我的情况,这是因为我安装了我以zip格式下载并解压缩到本地目录的软件包:

pip install -e path_to_downloaded_package_extracted

Obviously some files were not copied or some links were not created properly.

显然,某些文件未被复制或某些链接未正确创建。

Then i started a new virtual env and gave a try to tar.gz format as follows:

然后我开始了一个新的虚拟环境并尝试了tar.gz格式,如下所示:

pip install --no-index -f ~/path_to_local_cache django-autocomplete-light

Than it worked. All the files were up and running. Note that you must have all the required packages downloaded into the same directory for pip to deal with dependency chain.

比它工作。所有文件都已启动并正在运行。请注意,必须将所有必需的包下载到pip的同一目录中才能处理依赖关系链。