What's wrong with my filter query to figure out if a key is a member of a list(db.key) property?
Question: I'm having trouble retrieving a filtered list from google app engine datastore
(using python for server side). My data entity is defined as the following

    
    
    class Course_Table(db.Model):
        course_name = db.StringProperty(required=True, indexed=True)
        ....
        head_tags_1=db.ListProperty(db.Key)
    

So the head_tags_1 property is a list of keys (which are the keys to a
different entity called Headings_1).

I'm in the Handler below to spin through my Course_Table entity to filter the
courses that have a particular Headings_1 key as a member of the head_tags_1
property. However, it doesn't seem like it is retrieving anything when I know
there is data there to fulfill the request since it never displays the logs
below when I go back to iterate through the results of my query (below). Any
ideas of what I'm doing wrong?

    
    
    def get(self,level_num,h_key):
    path = []
    if level_num == "1":
        q = Course_Table.all().filter("head_tags_1 =", h_key)
    
        for each in q:
        logging.info('going through courses with this heading name')
        logging.info("course name filtered is %s ", each.course_name)
    

MANY MANY THANK YOUS


Answer: ~~I assume h_key is key of headings_1, since head_tags_1 is a list, I believe
what you need is IN
operator.<https://developers.google.com/appengine/docs/python/datastore/queries>~~

Note: your indentation inside the for loop does not seem correct.

My bad apparently '=' for list is already check membership. Using = to check
membership is working for me, can you make sure h_key is really a datastore
key class?

Here is my example, the first get produces result, where the 2nd one is not

    
    
    import webapp2 from google.appengine.ext import db
    
    class Greeting(db.Model):
        author = db.StringProperty()
        x = db.ListProperty(db.Key)
    
    class C(db.Model):  name = db.StringProperty()
    
    class MainPage(webapp2.RequestHandler):
        def get(self):
            ckey = db.Key.from_path('C', 'abc')
            dkey = db.Key.from_path('C', 'def')
            ekey = db.Key.from_path('C', 'ghi')
            Greeting(author='xxx', x=[ckey, dkey]).put()
            x = Greeting.all().filter('x =',ckey).get()
            self.response.write(x and x.author or 'None')
            x = Greeting.all().filter('x =',ekey).get()
            self.response.write(x and x.author or 'None')
    
    app = webapp2.WSGIApplication([('/', MainPage)],
                                  debug=True)
    

