Autocomplete Textbox Example in python + Google app engine
For my google app engine application, I need to include a autocompleter Textbox which will show the name starting with the textbox value.And the name will retrieve from the google app engine datastore.
Any good tutorial or sample code please.
Update: Please Answer for this
I created a sample HTML code : dl.dropbox.com/u/7384181/autocomplete/a开发者_如何学Goutocomplete.html . In this html page i have creating the textbox dinamically.So currently i assign the autocomplete in the first textbox(txtProduct1) only. How do i assign the autocomplete in rest all the textbox which is going to create dynamically ?
You can have a look at the jquery auto complete here
HTML :
$("#search_users").autocomplete(/search/search_manager);
python-controller:
jquery autocomplete plugin by default uses variable q
class search_user(webapp.RequestHandler):
q = (self.request.GET['q']).lower()
results=models.user.all().fetch(100)
for records in result:
print records+"|"+records+"\n"
application = webapp.WSGIApplication([
(r'/user_auth/search_manager',search_user)]
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
simple:
Apply the autocomplete to a class $
(".search_users").autocomplete(/search/search_manager);
Look into JQuery's autocomplete plugin, you can use a django template tag to populate the data. Below is an example if your data is separated by commas.
Python:
names=[name for name in db.GqlQuery("SELECT * FROM names")]
values={'names':','.join(names)}
self.response.out.write(template.render('template.html',values))
template.html:
var data = "{{names}}".split(",");
$("#example").autocomplete(data);
Using autocomplete with GAE Python and YUI3 AutoComplete Plugin.
精彩评论