title: SQLalchemy updating all rows instead of one
body: <p>This code is supposed to update a post in the database that matches 'post_id'. But it updates every post in the table.</p>
  
  <p><strong><em>The code has been edited so it works correctly.</em></strong></p>
  
  <pre><code>@app.route('/update/&lt;post_id&gt;', methods=['GET', 'POST'])
  def update(post_id):
    if 'username' not in session:
      return redirect(url_for('login'))
    post = Post.query.get(post_id)  
    form = PostForm(obj=post)
  
    if request.method == 'POST':
      if form.validate() == False:
        return render_template('update.html', form=form)
      else:
        Post.query.filter(Post.post_id==int(post_id)).update(dict(
          title=form.title.data, body=form.body.data))
        db.session.commit()
        return redirect(url_for('retrieve'))
  
    elif request.method == 'GET':
      return render_template('update.html', form=form, post_id=post_id)
  
  
  class Post(db.Model):
    __tablename__ = 'posts'
    post_id = db.Column(db.Integer, primary_key=True)
    author = db.Column(db.String(128))
    title = db.Column(db.String(128))
    body = db.Column(db.Text)
  
    def __init__(self, author, title, body):
      self.author = author
      self.title = title
      self.body = body
  
  &lt;form method="POST" action="/update/{{post_id}}"&gt;
  </code></pre>