title: Google App Engine join results of two tables
body: <p>I am developing a blog project using jinja2 for templates, Google App Engine for hosting and running it and Python as the server side language.</p>
  
  <p>So, my <code>models.py</code> looks like this : </p>
  
  <p>from google.appengine.ext import ndb</p>
  
  <pre><code>class User(ndb.Model):
      fullname = ndb.StringProperty(required=True)
      user_name = ndb.StringProperty(required=True)
      email = ndb.StringProperty(required=True)
      password = ndb.TextProperty(indexed=True,required=True)
      photo = ndb.StringProperty()
      location = ndb.StringProperty()
  
  
  class Post(ndb.Model):
      title = ndb.StringProperty(required=True)
      content = ndb.TextProperty(required=True)
      created = ndb.DateTimeProperty(auto_now_add=True)
      last_modified = ndb.DateTimeProperty(auto_now=True)
      user = ndb.KeyProperty(kind=User)
  </code></pre>
  
  <p>Now what I want is to have a result set like this : </p>
  
  <p><strong><code>User.fullname | User.Photo | Post.*</code></strong></p>
  
  <p>I am showing the above details for a single post. Now each <strong><em><code>Post</code></em></strong> entry is linked with a <strong><em><code>User</code></em></strong> with the User's Key. </p>
  
  <p>Now since joins are not supported in ndb query class, how do I fetch and merge the two results ?</p>
  
  <p>I tried the GQL like this : </p>
  
  <pre><code>select User.fullname, User.photo, User.id, Post.title, Post.content, Post.created
  from User, Post
  where User.__key__ == Post.user
  </code></pre>
  
  <p>But I get this error when I run this in the GQLQuery in my datastore console : </p>
  
  <blockquote>
    <p>GQL query error: Encountered "," at line 2, column 10. Was expecting
    one of: "group", "limit", "offset", "order", "where"</p>
  </blockquote>
  
  <hr>
  
  <p>Any suggestions ?</p>
  
  <p>TIA
  <hr>
  <strong>EDIT:1</strong>  Tried this query : </p>
  
  <p><code>posts = ndb.query(User,Post).filter(User.key == Post.user).order(-Post.created)</code></p>
  
  <p>But I get the following error: </p>
  
  <blockquote>
    <p>TypeError: 'module' object is not callable</p>
  </blockquote>
  
  <hr>
  
  <p><strong>EDIT:2</strong> Here is an index I tried : </p>
  
  <pre><code> kind: Post
    properties:
    - name: content
    - name: created
    - name: user
      direction: desc
  </code></pre>
  
  <p>But doesn't seem to work :O</p>