我有三个数据库表:
class Book(bd.Model):
title = db.StringProperty()
pub_time = db.DateTimeProperty()
subject = db.StringProperty()
class Author(db.Model):
name = db.StringProperty()
age = db.IntegerProperty()
class Match(db.Model):
bk = ReferenceProperty(Book, collection_name='book')
ath = ReferenceProperty(Author, collection_name='books_written')
问题:我想过滤作者写的书ATH
,关于主题SUB
我的方法:
class BookSearch(webapp2.requestHandler):
def post(self):
b = Books.all().filter("subject =", 'SUB')
a = Author.all().filter("name =", "ATH")
ret = Match.all().filter("bk =", b). filter("ath =", a)
self.response.out.write(ret.count())
但这不起作用,我得到一个错误:
BadValueError: Unsupported type for property : <class 'google.appengine.ext.db.Query'>