title: Length of list in jinja template, where the list is the result of a DBSession.query
body: <p>How do I find the length of a list of objects in a jinja template when the list of objects has been created by querying a database?</p>
  
  <p>I thought <code>There are {{ items|length }} items in this category.</code> would work, but items is a result of:</p>
  
  <pre><code>items = db_session.query(Item).filter_by(category_id=category.id)
  </code></pre>
  
  <p>and I get the error</p>
  
  <blockquote>
    <p>TypeError: object of type 'Query' has no len()</p>
  </blockquote>
  
  <p>Obviously, I could calculate the length separately and pass into <code>render_template()</code>, but I wondered if there was a better way?</p>
  
  <p>Any help from the community would be much appreciated :)</p>