I did something with jQuery.autocomplete with one model.
Functionality of the city of dating, when the user begins to write the name:
according to jqueryui docs, to make autocomplete work, you need this input:
<input id="n" type="text" name="n"/>
so the javascript in my template for attaching a library to this input is as follows:
$(document).ready(function(){ $( "input#n" ).autocomplete({ source: "{% url autocomplete_city %}", minLength: 2 }); });
to resolve this url you have to write something like this in urls.py
urlpatterns = patterns('cities.views', url(r'^autocomplete_city/$', 'autocomplete_city', name='autocomplete_city'), )
which means that I have something like city.views.autocomplete_city view:
def autocomplete_city(request): term = request.GET.get('term')
what else you need? start testing and remember DOCUMENTS - YOUR FRIEND, ASK first to do things for yourself, google, read the documents, try 3 times, if can not, stackoverflow is your friend.
source share