Am using JQuery Autocomplete on my 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,
max: 4,
highlight: false,
multiple: true,
multipleSeparator:",",
scroll: true,
scrollHeight: 300,
delay: 10
});
});
my AJAX django view that gets 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]
print results #shows me more than one item is returned
return HttpResponse('|'.join(results), mimetype='text/plain')