2

I've just installed Django-Autocomplete-Light and followed the guide on their site. I've setup the autocomplete-view and it works as intended (returning a JASON of autocomplete options). I can't seem to get the widgets to show up, though. in and out of the admin panel.

Everything compiles without errors but instead the widget I get an empty drop down selection box.

Image of empty selection box in admin panel

This is my settings.py:

INSTALLED_APPS = [
    'dal',
    'dal_select2',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'selectable',
    'videos.apps.VideosConfig',
]

This is views.py:

class ActorAutocomplete(autocomplete.Select2QuerySetView):
    def get_queryset(self):
        # Don't forget to filter out results depending on the visitor !

        qs = Actor.objects.all()

        if self.q:
            qs = qs.filter(name__istartswith=self.q)

        return qs

urls.py:

url(r'^actor-autocomplete/$', views.ActorAutocomplete.as_view(), name='actor-autocomplete'),

forms.py:

class ActorForm(forms.ModelForm):
    class Meta:
        model = Actor
        fields = ('name',)
        widgets = {
            'name': autocomplete.Select(url='videos/actor-autocomplete')
        }

It feels like I'm missing something simple, but I don't know what it is. Perhaps it can't access the static files, but adding 'dal' to installed_app in settings.py should have solved that according to the documentation. I'll appreciate any help!

I forgot to mention that Actor.name is of type CharField. Perhaps I'm not using the correct widget, but I haven't found one that is specific for CharField.

As I have the same problem, here is the content of my console in Firefox:

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.

It seems that jQuery is needed but not found, but I can't find a way to link it properly.

It is also running perfectly in Chromium. I don't have any other browser to test.

maddersky
  • 107
  • 1
  • 8
Curtwagner1984
  • 1,908
  • 4
  • 30
  • 48

2 Answers2

2

After some testing, I found out that this was working perfectly on Firefox and Chrome incognito mode. I've disabled all chrome extensions and now it works on my regular chrome as well.

The problem most likely was one of the extensions but I didn't manage to narrow it down to a specific extension.

TL;DR Changing the browser or opening the site from another chrome user fixes the problem for me.

Curtwagner1984
  • 1,908
  • 4
  • 30
  • 48
2

I did have the exact same problem. It is a problem due to the google chrome cache... It did take me a certain time to identify the cause... to solve it do ctrl + SHIFT + R

See this issue on DAL: github Issue 858

Maxime Deuse
  • 313
  • 11
  • 13