Typeerror With Get_or_insert
Here is my code. import webapp2 import json from google.appengine.ext import ndb class Email(ndb.Model): email = ndb.StringProperty() subscribed = ndb.BooleanProperty()
Solution 1:
The error is caused by passing ekey
(which is an ndb.Key
) as arg to get_or_insert()
(which expects a string):
ekey = ndb.Key("Email", email)
entity = Email.get_or_insert(ekey)
Since it appears you want to use the user's email as a unique key ID you should directly pass the email
string to get_or_insert()
:
entity = Email.get_or_insert(email)
Post a Comment for "Typeerror With Get_or_insert"