title: How to display next record in database by clicking button in Flask?
body: <p>I'm trying to make Flask application that will display in sequence title and content of articles stored in database by clicking in "Next" button but I don't know what I suppose to do below first "if" statment to fetch only one record from database. My current solutions lead to an error: <code>sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one()</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>flask import Flask, render_template, url_for, request
  from flask_sqlalchemy import SQLAlchemy
  
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////PATH/TO/DATABASE/KORPUS/Database.db'
  app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
  db = SQLAlchemy(app)
  
  class Polityka(db.Model):
      __tablename__ = 'polityka_articles'
      id = db.Column('id', db.Integer, primary_key=True)
      title = db.Column('article_title', db.Unicode)
      content = db.Column('article_content', db.Unicode)
  
  @app.route('/', methods=['GET', 'POST'])
  
  def index():
  
      next_item = request.form.get('next_item')
      data = Database.query.filter_by(column = 'Nauka').first()
  
      if next_item is not None:
          data = Polityka.query.filter_by(column = 'Nauka').one()
      return render_template('home.html', item_title = data.title, item_content = data.content)
  
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>And here is <code>home.html</code> file:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;!-- Required meta tag and CSS --&gt;
      &lt;title&gt;Site&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class='container'&gt;
  
          &lt;h1&gt;{{ item_title }}&lt;/h1&gt;
          &lt;p&gt;{{ item_content }}&lt;/p&gt;
  
      &lt;/div&gt;
      &lt;form method="POST" action="/"&gt;
          &lt;button type="submit" name="next_item" class="btn btn-success"&gt;Next&lt;/button&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I will be greatfull for any hints.</p>