class Order(db.Model):
id = db.Column(db.Integer, primary_key=True)
amount = db.Column(db.Integer)
description = db.Column(db.String)
paid = db.Column(db.Boolean, default=False)
from flask.ext.admin.contrib.sqla.view import ModelView, func
class PaidOrderView(ModelVew):
def get_query(self):
return self.session.query(self.model).filter(self.model.paid==True)
def get_count_query(self):
return self.session.query(func.count('*')).filter(self.model.paid==True)
https://github.com/mrjoes/flask-admin/blob/master/flask_admin/contrib/sqla/view.py#L654