PacktPublishing / Mastering-Flask-Web-Development-Second-Edition

Mastering Flask Web Development, published by Packt
MIT License
153 stars 112 forks source link

Chapter 4 issue #2

Closed alexberardi closed 5 years ago

alexberardi commented 5 years ago

In the Chapter 4 module, the function: def sidebar_data(): recent = Post.query.order_by(Post.publish_date.desc()).limit(5).all() top_tags = db.session.query( Tag, func.count(tags.c.post_id).label('total') ).join(tags).group_by(Tag).order_by('total DESC').limit(5).all() errors. You need to include sql along with func in the sqlalchemy import and then modify the join to be: join(tags).group_by(Tag).order_by(sql.text('total DESC')).limit(5).all()