Am using JQuery Autocomplete on my django templete, but as i get the
results the Autocomplete only displays one item despite that the
results that are fetched have more that one item. It only shows the
first item on the list!

Example:

if i have a result list with ('python', 'pythonism', 'pythodus')

and on the autocomplete i type 'pyt' it only displays 'python' on the
drop down!

My autocomplete code:

       $(document).ready(function(){
               $("#tags1").autocomplete("/taglookup/", {
                width: 320
               });
           })

My Ajax Django view that get called:

def tag_lookup(request):
    # Default return list
    results = []
    if request.method == "GET":
        if request.GET.has_key(u'q'):
            value = request.GET[u'q']
            # Ignore queries shorter than length 3
            if len(value) > 2:
                TI = Tag.objects.filter(name__contains=value)
                print TI
                results = [ x.name for x in TI]

    results = 'one|two|three'
    return HttpResponse(results, mimetype='text/plain')

for testing purposes am hard coding the results just to check the
behavior, so whenever ill type anything on the autocomplete field am
excepting it to display a drop down list of 'one, two, three' but it
only displays 'one'.

Any ideas?

Gath

Reply via email to