cannot use select2 on grappelli admin dashboard
See original GitHub issueHi,
I used from autocomplete light in grappelli dashboard but i got this error when load page,
Uncaught TypeError: $(...).select2 is not a function select2.js:8!!!
how can i fix this?!
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:37 (15 by maintainers)
Top Results From Across the Web
django-select2-admin-filters - Python package - Snyk
A simple extension to Django app to render filters in django admin panel as autocomplete widget. For more information about how to use...
Read more >Django Grappelli not selecting all on clicking select all checkbox
I am having some issues on my admin panel ...
Read more >django-select2-admin-filters - PyPI
A simple extension to Django app to render filters in django admin panel ... This extension is based on django-select2 and works with...
Read more >django-autocomplete-light Documentation
So, we're going to override the default ModelForm fields, to use a widget to select a Model with Select2, in our case by...
Read more >yourlabs - Bountysource
cannot use select2 on grappelli admin dashboard $ 0 ... Created 6 years ago in yourlabs/django-autocomplete-light with 37 comments. Hi,. I used from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi everyone,
Just for other which have this same JS error (without grapelli for me) : to fix the issue, drop the static dir before collecting it.
I think the same error should happen with grappelli and the
collectstaticcommand itself show us the fix :However, I didn’t understand that if the file was previously collected, it won’t be override. So even if
INSTALLED_APPSis correctly sorted, the command won’t override the previousadmin/js/jquery.init.jsfrom django.contrib.admin (or grapelli).By removing the file copied in static dir (or dropping the static dir itself), the next
collectstaticwill properly copied the first oneadmin/js/jquery.init.jsfounded, which is the one from dal due to ordering of the settingINSTALLED_APPS.At least for me, it fix this issue.
I’m not sure we could easily fix it, but we could add some note in install doc? For example:
INSTALLED_APPSadmin/js/jquery.init.js)python manage.py collectstaticJust in case, check that your served
jquery.init.jsis the one from dal.Hope it could help.
I’m using the default Django admin and I’m getting the same issue. I’m following the documentation to show a
ModelSelect2Multiple- I can get the form to show, but I get the error that the OP mentions.I also get
select2.full.js:473 Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page.- I can solve this with the code below in the admin class…… but I don’t think this is the solution. The installed apps layering does not do the trick either and I continue receiving the same error as the OP.
I’ve ran
collectstaticwith no luck. I’m guessing I need to load the jQuery file before the select2 based on other answers I’ve seen on StackOverflow.Has anybody seen something like this before? Django 1.9.2/DAL 3.1.8