// models.py
db.event.listen(User.declare, 'set', User.declare_cache)
File "E:\Program\python\1\myapp\models.py", line 156, in <module>
db.event.listen(User.declare, 'set', User.declare_cache)
AttributeError: 'SQLAlchemy' object has no attribute 'event'
1
florije 2016-01-19 12:46:47 +08:00
一般这么使用:
from sqlalchemy import event event.listen(something) |
2
skywatcher OP @florije 上面那么用是用的 Flask-SQLAlchemy ;但是你说的这招也用过了,报的错是: TypeError: 'InstrumentedAttribute' object is not callable
|
3
skywatcher OP @florije 对的,我之前忽略调用函数
|