ido roseman ido roseman - 7 months ago 99
Python Question

TypeError: Cannot filter a non-Node argument; received True

I'm trying to query GAE datastore with a list of possible values. something like:

list_of_assigned_therapists = [ ... ]
qry = Appointment.query(Appointment.therapist in list_of_assigned_therapists)

but I get the error in the title. the only refernce I found is when using properties not declared in the model. but my model looks like

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

and simple queries

qry = Appointment.query(Appointment.therapist == selected_therapist_key)

works fine, no error what so ever.

what am I doing wrong ???


The 'in' clause is not used as you are doing. You need to do this:

qry = Appointment.query(Appointment.therapist.IN(list_of_assigned_therapists))

See here.