python - Why are my app engine queries not finding my instances? -
I'm playing with an app engine, but I think the NDB datastore queries are misleading. I put the errors thrown next to the query.
Playing around in the Interactive Console:
Google.appengine.ext Import Ndb class client (ndb.model): email = ndb.StringProperty () name = ndb #StantProperty (indexed = true) #Instantiated client example ID 6578378068983808 with parameters below # Client = Client (email = "bryan@gmail.com", name = "Brian Wheelock"). Input () Client = Client.query (Client.name == 'Brian Wheelock') #client = Client Query (client.id == 6578378068983808) #Internet Enter: Type object 'Client' attribute 'id' #client = Client.all () # Enter attribute: Type object 'Client' has no attribute 'all' #client = Client Get_by_id (6578378068983808) # This Works gives you a printprint.print (customer.name) of U'brayan velock.
Examples of query engine app documentation done by me Sector'm right, that I do wrong?
question
The Client.query () returns the query object.
You must get the result from:
query = client.query (client.name == 'Brian Wheelock') client = query.get () # ago Results pprint.pprint (client.name)
Or just:
client = Client.query (Client.name == 'Brian Wheelock'). Get ID () pprint.pprint (client.name)
id
ID model is not a feature but its key is to bring client directly from your ID You can refer to model methods here for reference:
client = client.get_by_id (id)
>
Comments
Post a Comment