类型错误:无法过滤非节点参数;收到真

ido*_*man 0 python google-app-engine google-cloud-datastore

我正在尝试使用可能值列表查询 GAE 数据存储。就像是:

list_of_assigned_therapists = [ ... ]
qry = Appointment.query(Appointment.therapist in list_of_assigned_therapists)
Run Code Online (Sandbox Code Playgroud)

但我收到标题中的错误。我发现的唯一参考是使用模型中未声明的属性。但我的模型看起来像

class Appointment(BaseModel):
    therapist = ndb.KeyProperty(MyUser, required = True)
    Patient = ndb.KeyProperty(MyUser)
    when = TZDateTimeProperty(required = True)
    status = ndb.IntegerProperty(default = 1)
Run Code Online (Sandbox Code Playgroud)

和简单的查询

qry = Appointment.query(Appointment.therapist == selected_therapist_key)
Run Code Online (Sandbox Code Playgroud)

工作正常,没有任何错误。

我究竟做错了什么 ???

小智 5

'in' 子句没有像您那样使用。你需要这样做:

qry = Appointment.query(Appointment.therapist.IN(list_of_assigned_therapists))
Run Code Online (Sandbox Code Playgroud)

这里