Question

I am sorry if my query is stupid but please excuse me as i am new to google app engine and python I have and entity named Location

class Location(db.Model):
    place = db.StringProperty(required = True)
    address = db.TextProperty(required = True)
    approx_distance = db.StringProperty(required = True)

The GQL query

location = db.GqlQuery("SELECT * FROM Location WHERE place='Mumbai'")

gives an attribute error

 AttributeError: 'GqlQuery' object has no attribute 'place'

Please help

Was it helpful?

Solution

You should look at the line of code that error is happening on; it's not the lines you post. You're probably doing something like location.place later on, but location is a GqlQuery, not the results of the query. You probably want:

location = db.GqlQuery("SELECT * FROM Location WHERE place='Mumbai'").get()

To get the first result, or use fetch to get a list of results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top