'This view is used by the PageSmartLinkWidget as the user type to feed the autocomplete drop-down.'

def get_published_pagelist(self, *args, **kwargs):

    request = args[0]
    if request.is_ajax():
        query_term = request.GET.get('q', '').strip('/')
        language_code = request.GET.get('language_code', settings.LANGUAGE_CODE)
        matching_published_pages = self.model.objects.published().public().filter((((Q(title_set__title__icontains=query_term, title_set__language=language_code) | Q(title_set__path__icontains=query_term, title_set__language=language_code)) | Q(title_set__menu_title__icontains=query_term, title_set__language=language_code)) | Q(title_set__page_title__icontains=query_term, title_set__language=language_code))).distinct()
        results = []
        for page in matching_published_pages:
            results.append({'path': page.get_path(language=language_code), 'title': page.get_title(language=language_code), 'redirect_url': page.get_absolute_url(language=language_code)})
        return HttpResponse(json.dumps(results), content_type='application/json')
    return HttpResponseForbidden()
