python - How do I use get_or_insert in GAE? -
according documentation have pass in first key, , shall pass in properties initialise, model saved. of done in form of **kwargs.
the definition seems this:
def _get_or_insert(*args, **kwds):
this way intended use it, yet throws exception:
record1, is_created = record.get_or_insert(record_key, {'record_date' : event1.date_time, 'user' : user.key})
the model defined as:
class record(ndb.model): user = ndb.keyproperty(kind=user) record_date = ndb.dateproperty(required=true)
exception:
file "/applications/googleappenginelauncher.app/contents/resources/googleappengine-default.bundle/contents/resources/google_appengine/google/appengine/ext/ndb/model.py", line 3396, in _get_or_insert_async cls, name = args # these must positional. valueerror: many values unpack
any advice?
kwargs should passed key/value pairs. try like:
record1, is_created = record.get_or_insert(record_key, record_date = event1.date_time, user = user.key)
Comments
Post a Comment