Autofill text field example in python + google engine

For my app for Google app for apps, I need to include an autocomplete text box that will display a name starting with the text box value. And the name will be retrieved from the Google data store.

Any good tutorial or sample code, please.

Update: answer this

I created a sample HTML code: dl.dropbox.com/u/7384181/autocomplete/autocomplete.html . On this html page I am creating a text box dynamically. Therefore, at present, I assign autocomplete only in the first text box (txtProduct1). How to assign autocompletion at rest to the entire text field that will be dynamically created?

+6
source share
3 answers

You can look at jquery auto startup here

HTML:

$("#search_users").autocomplete(/search/search_manager); 

Python controller :

Jquery autocomplete plugin uses q variable by default

 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 autocomplete to class $

 (".search_users").autocomplete(/search/search_manager); 
+8
source

Take a look in jQuery autocomplete , you can use django template tag to populate 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); 
+2
source

Source: https://habr.com/ru/post/887606/


All Articles