AutoComplete With Django

8 views
Skip to first unread message

furqanmlk

unread,
Apr 2, 2012, 3:46:36 PM4/2/12
to Django users
Hi there,

Sorry for posting this question even it had been answered but i tried
all my best to solve this issue,
if use result list in Jquery code directly it works.

Here is code,
HTML:
<form method = "get">
<fieldset>
<label for="searchbox">Type Something:</label>
<input id="searchbox" type="text" name="n" />
</fieldset>
</form>

Jquery:
$(document).ready(function(){
$("#searchbox").autocomplete({

source: '{% url AutoCompleteSearch %}',
minLength: 2

});

});


View.py:

def AutoCompleteSearch(request):
#query = request.Get.get("q","")

#For Testing
results = []

results = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy blah",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
]


json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')

url.py:

url(r'^AutoCompleteSearch/$', AutoCompleteSearch),



Your help would greatle be appreciated.
Reply all
Reply to author
Forward
0 new messages