Flask-Admin User Read/Write Settings Per Row
It's pretty simple to override the queries that are produced by the backend in Flask Admin - you can do some quite complex things. Remember to override all of the below - especially get_one().
class BaseModelView(ModelView): def is_accessible(self): # if not authenticated we can't see this if not login.current_user.is_authenticated(): return False return True def get_query(self): return query.filter(self.model.parent_user_id.any(id=login.current_user.id)) def get_count_query(self): # faster count query! query = self.session.query(func.count('*')).select_from(self.model).filter(self.model.location_id == login.current_user.id) return query def get_one(self, id): """ Return a single model by its id. :param id: Model id """ result = self.session.query(self.model).get(iterdecode(id)) # if the users location does not exist and she is only allowed to edit locations they control if login.current_user.id != result.parent_user_id: app.logger.warn('You are not allowed to edit entries for this user.') abort(404) return result