title: How to limit text length outputting from database to browser in flask python
body: <p>You know how blogs work where a the homepage will vertically display all the posts but it will shorten the text and have a 'read more' link to go to the page of that article.</p>
  
  <p>I want to do that with my python/flask app because I don't want it to show the whole text of the post.  How would i shorten it's length for the homepage with python/flask/sqlalchemy?</p>
  
  <p>Here's some code for the view and the template</p>
  
  <pre><code>#loop through posts
  @app.route('/')
  def read():
      post = Post.query.filter_by(visibility='public').order_by(Post.published.desc()).all()
      return render_template('index.html', post=post)
  </code></pre>
  
  
  
  <pre><code>{% extends "bootstrap/base.html" %}
  {% import "bootstrap/wtf.html" as wtf %}
  
  {% block title %}
      booksummary app
  {% endblock %}
  
  {% block jumbotron %}
      &lt;div class="jumbotron"&gt;
      &lt;/div&gt;
  {% endblock %}
  
  {% block content %}
      {% if post %}
          {% for display in post %}
              &lt;article&gt;
                  &lt;h2&gt;&lt;a href="post/{{ display.url }}"&gt;{{ display.title }}&lt;/a&gt;&lt;/h2&gt;
  
                      &lt;p class="center"&gt;{{ display.author }} || {{ display.published.strftime('%b %d, %Y') }}&lt;/p&gt;
  
  
  
                  &lt;div class="text"&gt;
                      {{ display.body | safe }}
                  &lt;/div&gt;
              &lt;/article&gt;  
  
          {% endfor %}
      {% else %}
          &lt;div class="well"&gt;
              &lt;h2&gt;Sorry, there are no posts yet.  I am currently working on it&lt;/h2&gt;
          &lt;/div&gt;
      {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>I want the text of the 'post.body' part of it to be shortened for the homepage.  If there's a way to do that than please let me know. </p>