Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select2 fails on project with existing select2 dependency #38

Open
yuvadm opened this issue Jan 11, 2017 · 3 comments · May be fixed by #177
Open

Select2 fails on project with existing select2 dependency #38

yuvadm opened this issue Jan 11, 2017 · 3 comments · May be fixed by #177

Comments

@yuvadm
Copy link
Contributor

yuvadm commented Jan 11, 2017

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?

@asfaltboy
Copy link
Member

asfaltboy commented Jan 11, 2017

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.

@yuvadm
Copy link
Contributor Author

yuvadm commented Jan 12, 2017

@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.

@asfaltboy
Copy link
Member

asfaltboy commented Jan 12, 2017

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!

@asfaltboy asfaltboy linked a pull request Oct 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants