smac3
smac3

Reputation: 83

BadValueError: Expected GeoPt

I am trying to pass values from a html form into the gae datastore and receive the following error:

"BadValueError: Expected GeoPt, got (51.123, -0.123)"

Apologies up front, but I'm new to this so may be going about it all wrong but would really appreciate some advice on the best way of doing this.

Thanks in advance.

Upvotes: 3

Views: 594

Answers (2)

Ani
Ani

Reputation: 1457

I have never worked with GeoPt properties, but I would think that you passed a tuple of two floats.

Pass the value to ndb.GeoPt() first and store the return value in NDB. Example:

location = ndb.GeoPt(51.123, -0.123)

If you use the DB API of HRD rathern than the NDB API, use db.GeoPt() which is basically the same.

Upvotes: 1

Jon Wayne Parrott
Jon Wayne Parrott

Reputation: 1341

Looks like you're trying to assign a tuple to the property instead of a geopt.

Your code does this:

entity.some_geo_property = (51.123, -0.123)

Where it needs to do this:

from google.appengine.ext import ndb

entity.some_geo_property = ndb.GeoPt(51.123, -0.123)

alternatively using the tuple:

entity.some_geo_property = ndb.GeoPt(*value)

Without seeing your exact code it's hard to offer a complete solution. If you provide code I'll try to update my answer.

Upvotes: 6

Related Questions