Python 多租户应用程序无法遍历模型
我使用本指南创建多租户应用程序: 我遇到的问题是,向导正在这样做:Python 多租户应用程序无法遍历模型,python,postgresql,flask,sqlalchemy,flask-sqlalchemy,Python,Postgresql,Flask,Sqlalchemy,Flask Sqlalchemy,我使用本指南创建多租户应用程序: 我遇到的问题是,向导正在这样做: @simple\u缓存 def了解租户(): tenants=Tenant.query.all() 报税表[i.i租户的姓名] 我在做类似的事情: def了解组织(): organizations=Organization.query.all() 返回[o.organization\u name\u组织中o的url] 我是否因为错误而遗漏了什么 AttributeError:“非类型”对象没有属性“查询” 模型 任何帮助都
@simple\u缓存
def了解租户():
tenants=Tenant.query.all()
报税表[i.i租户的姓名]
我在做类似的事情:
def了解组织():
organizations=Organization.query.all()
返回[o.organization\u name\u组织中o的url]
我是否因为错误而遗漏了什么
AttributeError:“非类型”对象没有属性“查询”
模型
任何帮助都将不胜感激我猜您在定义方法之前错过了@simple\u cache。或者组织变量在任何情况下都会更新为其他无值。我发现了这个问题,似乎当我转到一个在postgres中没有特定数据库的url时,它无法对其进行迭代
class Organization(db.Model):
organization_id = db.Column(db.Integer, primary_key=True)
cypher = db.Column(db.String(10), unique=True, nullable=False) # 10-character String representation to use as ID of the organization
organization_name = db.Column(db.String(100), unique=True, nullable=False) # Organization name as String (ex: Seattle Children's Hospital)
organization_name_url = db.Column(db.String(100), unique=True, nullable=False) # Parsed organization name to lowercase and with dashes to use as subdomain (ex: seattle-childrens-hospital)
website = db.Column(db.Text, unique=True, nullable=False) # URL of the organization's website
contact_phone = db.Column(db.String(15), unique=True, nullable=False) # Organization's contact number
ooo_phone = db.Column(db.String(15), unique=True, nullable=False) # Omedyari number