crucialfelix / django-ajax-selects

jQuery UI-powered auto-complete fields for ForeignKey, ManyToMany and text fields
Other
822 stars 249 forks source link

AutoCompleteSelectMultiple add new stopped to work with Django 4.1 #297

Closed kalevhark closed 9 months ago

kalevhark commented 1 year ago

Hi! I used over the year django-ajax-select module (great thing!) in admin module and it's worked well. But now AutoCompleteSelectMultiple add new stopped to correctly work in every field. It still works well if choose/remove existing items but it's totally mess if I try to add new item. New popup window opens and I can add new item, then it closes, nothing happens. If I press "Save and continue to edit" it appears in deck. If I have existing selected items and then I try to add new item, it replaces previous items rather than add new item. Django version 4.1.5 and django-ajax-selects 2.2.0. No customizing. Thanks for helping!

crucialfelix commented 1 year ago

What changed? Something must have changed, resulting in it no longer working.

Did you update Django, django-ajax-selects or any of your connecting code?

kalevhark commented 1 year ago

I don't know. I tried to find reason several days. I tried in my app downgrade django version 4.1.5 -> 4.0.2 and django-ajax-select to 2.0.0. Nothing changed. Then I installed in new virtual environment example app from django-ajax-select git and it's also not working with Django 4.1.5 nor 4.0.2. Something wrong with sending back data to admin from popup window. I looked from DOM, for example if I choose from existing items, it looks pk correctly in in "|pk|" but if I add new item it places value without "|". If I choosed previously several items it show in DOM "|pk1|pk2|" but if I try to add new, it replaces it with "pk3" (not "|pk1|pk2|pk3|". My javascript skills are weak but maybe something related with new version of "RelatedObjectLookups.js" in django admin js pack.

kalevhark commented 1 year ago

Little update. I managed get it back work. Rolled back Django 4.1.5 -> 4.0.10. Removed from static admin js/css, made python manage.py collectstatic, restarted server and refreshed (shift+F5) admin page. Now everything works nice again! Tested with django-ajax-selects "example" app. It's works with 4.0.2, 4.0.5 and 4.0.10 neither with 4.1.0 or 4.1.5.

crucialfelix commented 1 year ago

Ok thanks for discovering the exact version that triggers it.

I should be able to fix, perhaps next week. I'm just returning from vacation.

crucialfelix commented 9 months ago

This is fixed now, works in Django 5 as well. Release coming shortly.

kalevhark commented 9 months ago

Works well! Thank You, Chris!