Monday, 23 September 2019

I am using flask ,flask_sqlalchemy paginate function works fine for page1 but it's not working for other page

I am connected to existing Ms Access data base.And my model looks like

class Suppliers(db.Model):

   __tablename__ = 'Suppliers'
   SupplierID = db.Column('SupplierID', db.Integer, primary_key=True)
   __table_args__ = {'autoload': True,'autoload_with': db.engine}
   def __repr__(self):
      return f"Suppliers('{self.SupplierID}', '{self.SupplierName}')"
   def as_dict(self):
      return {"SupplierID": self.SupplierID, "SupplierName": 
          self.SupplierName}

In the views my query works well only with page=1,but it is not working when page is more than 1 i.e when page=2;Paginate query returns all the item instead of item from 20 to 39(when page=2, per-page=20) and so on

 "sArgs": {"searchString": "sometext","searchPage": 1, "perPage": 20, "orderBy": "SupplierName"}

queryResults = Suppliers.query.filter(Suppliers.SupplierName).like('%'+sArgs['searchString']+'%'))
               .order_by(asc(sArgs['orderBy']
                )).paginate(
                page=int(
                    sArgs['searchPage']
                    ), per_page=sArgs['perPage']
                )

I am not able to find out what is the problem here.Please help me to find the solution. Thank you for your time.



from I am using flask ,flask_sqlalchemy paginate function works fine for page1 but it's not working for other page

No comments:

Post a Comment