title: Referencing values using foreign key on flask sql-alchemy
body: <p>I have models like this:</p>
  <pre><code>class User(db.Model):
      _tablename='user'
      id=db.Column(db.Integer, primary_key=True)
      name=db.Column(db.String)
      email=db.Column(db.String)
  
  class Post(db.Model):
      _tablename='post'
      id=db.Column(db.Integer, primary_key=True)
      title=db.Column(db.String)
      user=db.Column(db.Integer, db.ForeignKey('user.id'))
  </code></pre>
  <p>I would like to display the list of all posts on a web page, with something like this in html:</p>
  <pre><code>{% for entry in entries %}
      &lt;tr&gt;
         &lt;td&gt; {{ entry.id }} &lt;/td&gt;
         &lt;td&gt; {{ entry.title }} &lt;/td&gt;
         &lt;td&gt; {{ entry.user_name }} &lt;/td&gt;
         &lt;td&gt; {{ entry.user_email }} &lt;/td&gt;
  {% endfor %}
  </code></pre>
  <p>However, I don't know how to access the user and email from the user table, using the user.id foreign key. I tried</p>
  <pre><code>posts = Post.query.all()
  for post in posts:
      post.user_name = User.query.filter_by(id=post.id).first()
  return render_template('post.html', entries=posts)
  </code></pre>
  <p>But then instead of returning just the name and email, like the title from post, it is returning something like (u'User A',) and (u'test@test.com',).</p>