Home > database >  Flask-SQLAlchemy raises TypeError: Query.paginate() takes 1 positional argument but 4 were given
Flask-SQLAlchemy raises TypeError: Query.paginate() takes 1 positional argument but 4 were given

Time:10-21

I call Flask-SQLAlchemy's query.paginate method with arguments. Recently this stopped working and instead raised a TypeError. How do I pass page and other arguments to query.paginate?

Ticker.query.paginate(page, app.config["TICKERS_PER_PAGE"], False)
TypeError: Query.paginate() takes 1 positional argument but 4 were given

CodePudding user response:

As of Flask-SQLAlchemy 3.0, all arguments to paginate are keyword-only.

Ticker.query.paginate(page=page, per_page=app.config["TICKERS_PER_PAGE"], error_out=False)
  • Related