Search code examples
jquerydjangodjango-ajax-selects

How do I upgrade django-ajax-selects


I had django-ajax-selects installed a long time ago which was version 1.2.4. It worked great. It seemed to have some bug with ManyToMany fields which I'm trying to implement now, so I upgraded to 1.3.3. Now nothing is working.

According to the documentation I think my original configuration should work fine (ie, a few custom lookup channels, make_ajax_field constructor in some front facing forms, etc.). So I haven't changed my code at all.

The HTML looks correct, I think: I see the ajax_select attributes, the on_deck div, etc. But typing in the inputs doesn't actually pull any results. In the chrome debug box I don't see any url calls actually being made like I do on my original version. If I go to the URL myself it returns JSON results so I think the backend stuff is working fine.

Update: I'm not sure that the javascript is being loaded correctly. On my frontend pages I don't see the js listed under chrome developer tools - sources. In my admin pages it does seem to load the js but then the js console shows "Cannot read property 'fn' of undefined" under ajax_select.js. So, the dropdown behavior is missing there also.

Update 2: I removed AJAX_SELECT_BOOTSTRAP = True from settings.py and it works perfectly fine but only in the admin. If it set it to false it still doesn't work; the entire line has to be removed. However, none of those combinations cause it to work in on my frontend site which uses a bootstrap theme and is already loading jquery, jqueryui in the head element.

Any thoughts? I can't even downgrade back to 1.2.4 via pip since it doesn't seem to find that version.


Solution

  • I figured out a solution but am not sure exactly why its needed:

    I removed AJAX_SELECT_BOOTSTRAP = True. As I said above, I had to completely remove the line, not just set it to false. After doing this any admin forms worked correctly.

    Then I added this to my front-end pages:

    Now it seems to be working perfectly.