0

Am working on GAE with python. How to construct and store the latitude and longitude using GeoPoint?

This is my DB

class Customer(db.Model):
    name = db.StringProperty()
    address= db.PostalAddressProperty()
    geopoint= db.GeoPtProperty()

My code

class AddCustomerHandler(BaseHandler):
    input_fullname=self.request.get('fullname')
    input_cusaddress=self.request.get('cusaddress')
    input_latitude=self.request.get('latitude')
    input_longitude=self.request.get('longitude')


    input_geopoint= GeoPoint(input_latitude, input_longitude)
    logging.info('****************** xxxx= %s', input_geopoint)

    newcustomer=Customer(name=input_fullname,address=input_cusaddress,geopoint=input_geopoint)
    newcustomer.put()

Am trying this code. But Am getting error. How to store this geopoint field?

Tim
  • 41,901
  • 18
  • 127
  • 145
Baskaran
  • 39
  • 1
  • 9

1 Answers1

1
input_geopoint= GeoPoint(input_latitude, input_longitude) NameError: global name 'GeoPoint' is not defined.

Am getting this error

You're getting that error because you don't have the module imported where GeoPoint is defined.

Add this import

from google.appengine.api import search

and then use like this

input_geopoint = search.GeoPoint(input_latitude, input_longitude)

Also see the docs

Tim
  • 41,901
  • 18
  • 127
  • 145