Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 flask-admin 为我的数据库创建一个简单的后端。我只想根据用户拥有的权限基于预过滤显示表格的一部分。例如,如果表中有一家公司的所有销售额,我想只在 'foo' 访问后端时显示销售员 'foo' 的销售额
我发现解决方案是覆盖方法'get_query'
它应该返回一个 SQLAlchemy 查询对象。
def get_query(self): role = current_user.role if role == 'contributor': return # filtered query elif role == 'admin': return # unfiltered query