错误图:好像是函数传参的类型出错  但是找不到哪里错了

注册模板上下文的函数
# 注册模板上下文处理函数
def register_templates_context(app):
    @app.context_processor
    def templates_globals():
        categories = Category.query.order_by(Category.name).all()
        return dict(categories=categories)
模板部分代码
    {% if categories %}
    <div class="fenlei">
      <h2>分类</h2>
      <ul>
          {% for category in categories %}
              <li><a href="/">{{ category.name }}({{ category.posts|length }})</a></li>
          {% endfor %}
      </ul>
    </div>
    {% endif %}``