6

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/autocomplete.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 ?

topchef
  • 17,019
  • 8
  • 58
  • 98
Nijin Narayanan
  • 2,243
  • 1
  • 26
  • 44
  • possible duplicate of [Create Form Auto Complete in Google App Engine](http://stackoverflow.com/questions/4243570/create-form-auto-complete-in-google-app-engine) – Nick Johnson Oct 25 '11 at 02:40

3 Answers3

8

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);
Abdul Kader
  • 5,339
  • 4
  • 20
  • 37
  • 4
    You're not using `q` in the datastore query! – Nick Johnson May 09 '11 at 19:02
  • Hi @Abdulkader, I am unable to see the original code by the OP. I have asked a similar question and I wonder if you could take a look. I would appreciate it so much: http://stackoverflow.com/questions/25979567/jquery-autocomplete-with-remote-json-source-google-app-engine-python – hyang123 Oct 04 '14 at 19:01
2

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);
garnertb
  • 8,822
  • 29
  • 38
0

Using autocomplete with GAE Python and YUI3 AutoComplete Plugin.

topchef
  • 17,019
  • 8
  • 58
  • 98
  • If you identify a duplicate, you should flag it as such - not post your answer to both of them. – Nick Johnson Oct 25 '11 at 02:40
  • @NickJohnson - thanks for your suggestion that I'll follow when appropriate. But I didn't identify duplicates - you did. I happened to answer two related questions with the reference to the same blog that addresses both questions and some more. – topchef Oct 25 '11 at 05:20
  • Because both questions are _identical_, which you must have noticed when you answered both. – Nick Johnson Oct 25 '11 at 23:00