(request, *args, **kwargs)
return HttpResponse(json.dumps(data), "text/plain")
Returns data for jQuery UI autocomplete.

    @param request: Django Request.
Returns data for jQuery UI autocomplete.
Returns data for jQuery UI autocomplete .
def view_books_autocomplete(request, *args, **kwargs):
    """
    Returns data for jQuery UI autocomplete.

    @param request: Django Request.

    """

    term = request.GET.get("term", "").lower()
    book = request.GET.get("book", "").lower()

    if not book:
        books = models.Book.objects.filter(hidden=False).order_by("title")
        data = [dict(label_no_use=book.title, value=book.url_title)
                for book in books
                if not term or (term in book.title.lower() or
                                term in book.url_title)]
    else:
        chapters = models.Chapter.objects.filter(book__url_title=book)
        data = [dict(label_no_use=chapter.title, value=chapter.url_title)
                for chapter in chapters
                if not term or (term in chapter.title.lower() or
                                term in chapter.url_title)]

    return HttpResponse(json.dumps(data), "text/plain")
def view_books_autocomplete ( request , * args , * * kwargs ) : term = request . GET . get ( "term" , "" ) . lower ( ) book = request . GET . get ( "book" , "" ) . lower ( ) if not book : books = models . Book . objects . filter ( hidden = False ) . order_by ( "title" ) data = [ dict ( label_no_use = book . title , value = book . url_title ) for book in books if not term or ( term in book . title . lower ( ) or term in book . url_title ) ] else : chapters = models . Chapter . objects . filter ( book__url_title = book ) data = [ dict ( label_no_use = chapter . title , value = chapter . url_title ) for chapter in chapters if not term or ( term in chapter . title . lower ( ) or term in chapter . url_title ) ] return HttpResponse ( json . dumps ( data ) , "text/plain" )