简体   繁体   中英

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. 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. The autocomplete request should be visible here: try to open it manually, play with the GET parameters and see if it works as expected.

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.

Thanks to jpic, using FireBug I've found that the error was "Cannot resolve keyword 'name'".

I solved adding related_name='name' to the model's foreignkey involved in this autocomplete thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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