8.2.10.4.1.2.105. get_query

ModelView.get_query() sqlalchemy.orm.query.Query[source]

Return a query for the model type.

This method can be used to set a “persistent filter” on an index_view.

Example:

class MyView(ModelView):
    def get_query(self):
        return super(MyView, self).get_query().filter(
            User.username == current_user.username
        )

If you override this method, don’t forget to also override get_count_query, for displaying the correct item count in the list view, and get_one, which is used when retrieving records for the edit view.