gpt4 book ai didi

jquery - django 管理和自动完成灯 : Select2: An instance of jQuery or a jQuery-compatible library was not found

转载 作者:行者123 更新时间:2023-12-03 17:16:24 24 4
gpt4 key购买 nike

对于我尝试在管理中对其进行编码的字段,自动完成灯小部件未完全加载。相反,我得到以下信息

Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page.



旁边有一个只有一个选项的选择框。

这类似于之前关于 select2 库的几个问题,大多数解决方案都涉及重新排序 settings.py 中的文件或运行 python manage.py collectstatic。但到目前为止,这些都没有对我有用。

任务是在我的网页上的 Select2 之前包含 jQuery...怎么做?

最佳答案

我遇到了同样的问题,我能够通过重新配置 INSTALLED_APPS 来解决它在我的 settings.py文件以确保'dal''dal_select2'都包含在 'django.contrib.admin' 之前。
这个小花絮包含在 installation documentation 中为 django-autocomplete-light ,虽然我在最初的通读中错过了它:

Then, to let Django find the static files we need by adding to INSTALLED_APPS, before django.contrib.admin and grappelli if present:

'dal',
'dal_select2',
# 'grappelli',
'django.contrib.admin',

This is to override the jquery.init.js script provided by the admin, which sets > up jQuery with noConflict, making jQuery available in django.jQuery only and not $.


附言我最终发现 django 2.x+ 现在有一个 built-in for auto-complete fields .我最终改为使用它,并强烈推荐它以降低开销/开发成本。

关于jquery - django 管理和自动完成灯 : Select2: An instance of jQuery or a jQuery-compatible library was not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45665527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com