我有一個ndb模型,我使用Python +谷歌appengine。我想將主鍵添加到我的第一個字段「名稱」。例如,我添加了一個名稱「Ada」,之後如果我想再次添加「Ada」,它不會添加,它會給我一個錯誤。我可以用django輕鬆完成,但我無法用google appengine弄清楚。你能告訴我一種解決方法嗎?這裏是我的代碼:谷歌Appengine數據存儲我想添加primary_key
class User(ndb.Model):
username = ndb.StringProperty(indexed=False)
created_date = ndb.DateTimeProperty(auto_now_add=True)
updated_date = ndb.DateTimeProperty(auto_now_add=True)
我認爲這是你正在尋找的東西:http://squeeville.com/2009/01/30/add-a-unique-constraint-to-google-app-engine/ – rajpy