简体   繁体   English

django-autocomplete-light:“无法加载结果”

[英]django-autocomplete-light: "The results could not be loaded"

I'm developing a small project in Django and I would like to use the django-autocomplete-light plugin in a specific admin form field.我正在 Django 中开发一个小项目,我想在特定的管理表单字段中使用django-autocomplete-light 插件 I'm following this simple tutorial: link我正在关注这个简单的教程: 链接

The autocomplete field has been populated but when I start searching it prompt " The results could not be loaded ".自动完成字段已填充,但当我开始搜索时提示“无法加载结果”。

I don't understand why.我不明白为什么。

In this case, the first thing to check is your view.在这种情况下,首先要检查的是您的视图。 Opening firebug or webkit inspector on the Network tab displays the network requests.在网络选项卡上打开 firebug 或 webkit 检查器会显示网络请求。 The autocomplete request should be visible here: try to open it manually, play with the GET parameters and see if it works as expected.自动完成请求应该在这里可见:尝试手动打开它,使用 GET 参数并查看它是否按预期工作。

If it does, again in the inspector, in the Scripts tab, place a breakpoint in the processResults function and ensure that it returns the proper data for select2.如果是,再次在检查器中的脚本选项卡中,在processResults 函数中放置一个断点并确保它为 select2 返回正确的数据。

Thanks to jpic, using FireBug I've found that the error was "Cannot resolve keyword 'name'".感谢 jpic,使用 FireBug 我发现错误是“无法解析关键字'name'”。

I solved adding related_name='name' to the model's foreignkey involved in this autocomplete thing.我解决了将related_name='name'添加到此自动完成操作中涉及的模型外键的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM