title: NDB query filter by KeyProperty
body: <p>I have a class method in a ndb model, where I am filtering by 'user' (no problem with that) and by 'industry'.</p>
  
  <p>The problem is that the entity <strong>Recommendation</strong> doesn't has <em>industry</em> property, but has <em>stock</em> property that is a KeyProperty of Stock, and <strong>Stock</strong> has a <em>industry</em> property</p>
  
  <p>How can a fix the <strong>get_last_n_recommendations_for_user_and_industry</strong> method to filter by Industry, that is a KeyProperty of Stock??</p>
  
  <pre><code>class Industry(ndb.Model):
      name = ndb.StringProperty()
      ...
  
  class Stock(ndb.Model):
      name = ndb.StringProperty()
      industry = ndb.KeyProperty(kind=Industry)
      ...
  
      @classmethod
      def get_industry(cls):
          return cls.query(cls.ticker == cls).get().industry
  
  class Recommendation(ndb.Model):
      user = ndb.KeyProperty(kind=User)
      stock = ndb.KeyProperty(kind=Stock)
      ...
  
      @classmethod
      def get_last_n_recommendations_for_user_and_industry(cls, stock_key, user_key, n):
          return cls.query(
                  cls.user == user_key, 
                  cls.stock.get().industry == ndb.Key('Stock', stock_key.string_id()).get().industry
              )
              .fetch(page_size)
  </code></pre>
  
  <p>When I do this, I have this error:</p>
  
  <pre><code>AttributeError: 'KeyProperty' object has no attribute 'get'
  </code></pre>