我正在为我的应用使用Flask并获取 AttributeError:' _Option'对象没有属性' _sa_instance_state' 错误。不知道它是什么。我谷歌它似乎是一个SQL-Alchemy问题。你可以帮帮我吗?
这是我的models.py:
#current table is used to make navigation hierarchy. eg. menu/submenu
#eg. About Us (History, Mission, Vision)
menu_hierarchy = db.Table('menu_hierarchy',
db.Column('parent_id', db.Integer, db.ForeignKey('menu.id')),
db.Column('child_id', db.Integer, db.ForeignKey('menu.id'))
)
class Menu(db.Model):
"""Menu is used for websites navigation titles.
eg. Home/About Us/Blog/Contacts/and etc"""
id = db.Column(db.Integer, primary_key = True)
title = db.Column(db.String(255))
title_eng = db.Column(db.String(255))
alias = db.Column(db.String(255))
menu_type = db.Column(db.String(10))
ordering = db.Column(db.SmallInteger, default = '1')
check_out_time = db.Column(db.DateTime)
access = db.Column(db.String(30))
published = db.Column(db.SmallInteger, default = '1')
parent_id = db.relationship('Menu',
secondary = menu_hierarchy,
primaryjoin = (menu_hierarchy.c.parent_id == id),
secondaryjoin = (menu_hierarchy.c.child_id == id),
backref = db.backref('menu_hierarchy', lazy = 'dynamic'),
lazy = 'dynamic')
content = db.Column(db.String)
content_eng = db.Column(db.String)
image = db.Column(db.String(350))