pyutil / django-admin-autocomplete-all

Django admin: Use select2 (autocomplete_fields) everywhere. Implicit is better than explicit. Because it is brief and easy. Plus: gives better context if you try filter the content in autocomplete fields.
MIT License
14 stars 4 forks source link

autocomplete_all failing in TabularInline with Django 3.2 #2

Closed matthewn closed 3 years ago

matthewn commented 3 years ago

Have been using autocomplete_all successfully in a Django 2.2 project for over a year.

In migrating to Django 3.2, I cannot get autcomplete_all to work on TabularInlines. The admin page renders, but when I click the autocomplete widget in the inline, I get this in the browser's js console:

Uncaught TypeError: string.replace is not a function [autocomplete_all.js:88:23]

This happens in both Chrome and Firefox. If I replace autocomplete_all's TabularInline with Django's, it works, but of course I lose the autocomplete that my users depend on.

Any thoughts on troubleshooting this?

pyutil commented 3 years ago

Hi matthewn, I made a testing project with CharField-s only - but I haven't encountered this problem. Then I have added some IntegerField as search_fields in the parent table - but I haven't encountered this problem.

Then I stopped the simulation attempts and I made some fix attempt:

In static/autocomplete_all/js/autocomplete_all.js in expand_ajax_params, sanitize I have added the code to always convert the parameter to string.

So, please, can you install (from PyPI as usual) the current (0.6.5) version and check how it behaves?

I don't know if you use such functionality, but there is a possibility to limit (filter) the shown choices. If so, maybe the filtering expression can be a reason of problems (if it is not a string). But ... please check the updated version and let me know.

Best regards, Mirek

matthewn commented 3 years ago

Hi, Mirek. I do not use the choice-limiting functionality. And version 0.6.5 works for me! Thank you very much for the quick fix, and for this useful app!