django-advanced-filters
django-advanced-filters copied to clipboard
Select2 fails on project with existing select2 dependency
I'm trying to integrate advanced_filters into a project that already uses django_select2 and has SELECT2_CSS and SELECT2_JS settings set, but there are JS console errors that select2 is not a function.
The only difference I can see is that my select2 major version is 4.x.x while you expect 3.x.x.
Any thoughts?
Beh, this dependency keeps biting us in the backside. We do not support select2 4.X.
To fix this, we'd have to prefix our settings to avoid that I guess (e.g ADVANCED_FILTERS_SELECT2_CSS).
Right now, as a workaround, I suggest you subclass AdvancedFilterForm and update the Meta class to the correct (3.0) version of select2. Of course to use this new form class, you'd have to subclass AdminAdvancedFiltersMixin and set it's form property accordingly:
class MyAdminAdvancedFiltersMixin(AdminAdvancedFiltersMixin):
advanced_filter_form = MyAdvancedFilterForm
Note: I mentioned the implication of updating select2 to >= 4 in this comment.
@asfaltboy I'm not sure if I should be including duplicate v3 and v4 select2 client side dependencies at the same time. I'd rather attempt to fix the root problem in v4. Can you expand on what the problem is? Just to reiterate, I'm not sure the console error I'm seeing is related to what you're describing.
I've done some work that fixed the syntax errors a while back but stashed it, see the feature/select2-upgrade branch if you want to continue from there.
The important thing is that we need to support custom values entered by user, which the current implementation doesn't allow by default.
We would probably need to start using "tags"; as detailed in these SO answer: http://stackoverflow.com/a/30019966/484127 http://stackoverflow.com/a/30021059/484127
By the way, if you do decide to work on it, supporting both versions would be amazing!