I need to check datastore if entity kind "Kayit" exist to create new . my db.model class:
class Kayit(db.Model):
url=db.StringProperty()
date = db.DateTimeProperty(auto_now_add=True)
currently using this to check but it doesnt seem elegant
class MainPage(webapp2.RequestHandler):
def get(self):
r_name="none"
q=db.Query(Kayit)
try:
self.response.write(q[0].url)
except:
kay=Kayit(parent=_DefterKey(r_name),key_name='alibaba')
kay.url="some url"
kay.put()
I guess we get the parent key with db.Key.from_path('Kayit', 1) . how can I use to check if it has entities?