【python – 了解ndb密钥类与KeyProperty】教程文章相关的互联网学习教程文章

Python-如何设置NDB keyProperty【代码】

我在了解实体和键在Google App Engine NDB中的工作方式时遇到了一些麻烦. 我有一个帖子实体和一个用户实体.如何设置发布到用户的user_key? 到目前为止,在交互式控制台中:from google.appengine.ext import ndb from app.lib.posts import Post from app.lib.users import User from random import shuffleusers = User.query() posts = Post.query().fetch()for post in posts:post.user_key = shuffle(users)[0]post.put()我只是...

python – 了解ndb密钥类与KeyProperty【代码】

我查看了文档,文档和SO问题和答案,并且仍在努力理解其中的一小部分内容.您应该选择哪个以及何时选择? 这是我到目前为止所读到的(只是示例): > ndb documentation> movie database structure on SO> Parent Key issues 关键课对我来说似乎很简单.创建ndb实体时,数据存储区会自动为您创建一个键,通常以key(Kind,id)的形式为您创建id. 所以说你有这两个模型:class Blah(ndb.Model):last_name = ndb.StringProperty()class Blah2(nd...