However, with this , pagination does not work and I get an error - AttributeError: 'Query' object has no attribute 'paginate'
Can you please help?
Simon King
unread,
Jan 8, 2014, 12:39:16 PM1/8/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlal...@googlegroups.com
There are a couple of options. One would be to configure your
"db.session" object to use the Flask-sqlalchemy query class, rather
than the default SQLAlchemy one. The Session class constructor has a
query_cls parameter for this purpose - you'd want to pass
flask_sqlalchemy.BaseQuery. I don't use Flask, so I don't know how
your session is currently being configured.
Another option would be to use the with_entities method of Query to
change the set of columns that are being queried for:
so you could write something like "Article.query.with_entities('id',
'title', 'Author').from_statement(...)"
But I guess what you are really trying to do is to query Articles, but
only to load certain columns. You might be interested in using
"load_only" instead: