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

autocomplete.ModelSelect2 does not work, there is no any choice for it #724

Closed
JohnaXu opened this issue Jul 29, 2016 · 5 comments
Closed

Comments

@JohnaXu
Copy link

JohnaXu commented Jul 29, 2016

I am sorry to ask help from you , that is I want to use django-autocomplete-light for the foreign key in the form. But it returns me the error as follows:
select2.js:25 Uncaught TypeError: $(...).select2 is not a function(anonymous function) @ select2.js:25jQuery.event.dispatch @ jquery.js:4435elemData.handle @ jquery.js:4121jQuery.event.trigger @ jquery.js:4350(anonymous function) @ jquery.js:4901jQuery.extend.each @ jquery.js:374jQuery.fn.jQuery.each @ jquery.js:139jQuery.fn.extend.trigger @ jquery.js:4900initialize @ autocomplete.init.js:45jQuery.extend.each @ jquery.js:374jQuery.fn.jQuery.each @ jquery.js:139(anonymous function) @ autocomplete.init.js:50fire @ jquery.js:3099self.fireWith @ jquery.js:3211jQuery.extend.ready @ jquery.js:3417completed @ jquery.js:3433

With the help of this

link:http://stackoverflow.com/questions/37143571/django-autocomplete-light-not-working-select2-is-not-a-function/38719460#38719460

I rearranged the INSTALLED_APPS in the settings.py as follows:
INSTALLED_APPS = [ 'admin_bootstrapped_plus', 'django_admin_bootstrapped', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'dal', 'dal_select2', "webui", "membership", "hotel", "transaction", 'django.contrib.admin', "gunicorn", ]
But the error is also there.

According to this link:

http://stackoverflow.com/questions/20034522/select2-is-not-a-function

the error raises if your js files where you have bounded the select2 with select box is loading before select2 js files. Please make sure files should be in this order like:Jquery, select2 js, your js.

But I do not know how to reorder them.

@jpic
Copy link
Member

jpic commented Sep 24, 2016

It's in your template.

@jpic
Copy link
Member

jpic commented Oct 17, 2016

Hi ! Did you figure it out ? Moved on ?

@JohnaXu
Copy link
Author

JohnaXu commented Oct 18, 2016

Iam sorry that I already forget this problem and use other technology solve it

@jpic
Copy link
Member

jpic commented Oct 18, 2016

Awesome, thanks for the info !

@jpic jpic closed this as completed Oct 18, 2016
@crazyzubr
Copy link

I have this problem with Django 1.10.1 and default admin. After upgrade Django to 1.10.3 problem disappeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants