Autocompletion not showing in the UI

Issue #31 invalid
Former user created an issue

Autocompletion is not showing in the UI. Here is my configuration:

settings.py

INSTALLED_APPS = (
    ...
    'postman',
    'ajax_select',
    ...
)

# django-postman configuration
POSTMAN_DISALLOW_ANONYMOUS = True
POSTMAN_AUTO_MODERATE_AS = True
POSTMAN_AUTOCOMPLETER_APP = {
    'arg_default': 'postman_users'
}

# django-ajax-selects configuration (used by django-postman)
AJAX_LOOKUP_CHANNELS = {
    'postman_users': ('myapp.lookups', 'MessageRecipientLookup')
}
AJAX_SELECT_BOOTSTRAP = True
AJAX_SELECT_INLINES = 'inline'  # include js/css code used by autocomplete in html

urls.py

    url(r'^intern/messages/lookups/',
        include(ajax_select_urls)),

    url(u'^intern/messages/',
        include('postman.urls')),

MessageRecipientLookup.py

from django.core.exceptions import PermissionDenied

from ajax_select import LookupChannel

from django.contrib.auth.models import User


class MessageRecipientLookup(LookupChannel):
    model = User
    search_field = 'username'

    def get_query(self, entered_username, request):
        user = request.user
        found_users_qs = User.objects.filter(groups__in=user.groups.all)
        found_users_qs = found_users_qs.exclude(pk=user.pk).filter(username__icontains=entered_username)
        found_users_ordered_qs = found_users_qs.order_by('username')
        return found_users_ordered_qs

    def check_auth(self, request):
        if not request.user.is_authenticated:
            raise PermissionDenied

In JavaScript on page load window.addAutoComplete() is called with correct id "id_recipients". Then autocompletehtml() is called and the page is rendered.

When typing the first letter in the "id_recipients" field, in Django ajax_select.views.ajax_lookup(request,channel) is called. It calls myapp.lookups.MessageRecipientLookup.get_query() which returns the correct query set. Then its JSON format is returned by ajax_lookup().

But then no autocompletion is shown in the UI field (_renderItemHTML() is NOT called).

Did I miss something in the configuration?

Best regards,

Nikolay

Comments (5)

  1. Former user Account Deleted

    requirements.txt

    django-ajax-selects==1.2.5
    django-notification==1.0
    # latest postman (2.1.1) release is not compatible with the latest django-notification
    https://bitbucket.org/psam/django-postman/get/622b870.tar.gz#egg=django-postman
    
  2. Log in to comment