Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在ReferenceProperty';你想工作吗?_Python_Google App Engine_Google Cloud Datastore - Fatal编程技术网

Python 如何在ReferenceProperty';你想工作吗?

Python 如何在ReferenceProperty';你想工作吗?,python,google-app-engine,google-cloud-datastore,Python,Google App Engine,Google Cloud Datastore,我正在尝试使用引用实体中的查询集合_集进行筛选和获取,如下所示: class Author (db.Model) name = db.StringProperty() class Book (db.Model) author = db.ReferenceProperty (collection_name="books", indexed=True) name = db.StringProperty() author = Author.get (author_key) q =

我正在尝试使用引用实体中的查询集合_集进行筛选和获取,如下所示:

class Author (db.Model)
   name = db.StringProperty()

class Book (db.Model)
   author = db.ReferenceProperty (collection_name="books", indexed=True)
   name = db.StringProperty()

author = Author.get (author_key)
q = author.books
q.filter ("name =", "BOOK_NAME")
books = q.fetch(5)
我不是为了还书才拿到这个的。以及以下工作:

author = Author.get (author_key)
q = Book.all()
q.filter ("author =", author.key())
q.filter ("name =", "BOOK_NAME")
books = q.fetch(5)
那么前者应该有效吗

另外,推荐的最佳实践是什么?使用authors集合集合或使用author.key()的筛选器


谢谢。

我想你想要的是
对象。filter(field=“value”)
不是
对象。filter(“field=”,some\u value)
在这种情况下“objects”不是db.Query类实例吗?在其他情况下,此“q.filter”(“field=”,value)”有效:(谢谢)