Autocompletion not showing in the UI
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)
-
Account Deleted -
Account Deleted Same result with django-postman==3.0.0
-
Account Deleted Sorry, the error was in my front-end templates.
-
Account Deleted - changed status to resolved
Front-end error.
-
repo owner - changed status to invalid
- Log in to comment
requirements.txt