简体   繁体   中英

How to set GeoPtProperty ?google app engine

I have this model:

class location(ndb.Model):
      geoLocation = ndb.GeoPtProperty()

I am using this function to declare location model :

def careateLocationMode(cls,lon,lat):
        location1 = location()
        location1.geoLocation.lat = lat
        location1.geoLocation.lon = lon

but I got this error : NoneType' object has no attribute 'lat'

what's the problem ?

From NDB Document

You can construct one with two floats like ndb.GeoPt(52.37, 4.88) or with a string ndb.GeoPt("52.37, 4.88"). (This is actually the same class as db.GeoPt)

So the assignment is

location1.geoLocation = ndb.GeoPt(lat,lon)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM