我正在使用 Pyramid + SQLAlchemy 并进行了以下设置
from sqlalchemy import orm
from __init__ import user_table
from device import Device
class User(object):
def __repr__(self):
return 'User: ' + self.username
orm.mapper(User, user_table, properties={
'devices': orm.relation(Device, backref='owner')
})
访问时如何添加过滤器user.devices
?当我尝试user.devices.filter(Device.platform==1).all()
时,我收到以下错误:
'InstrumentedList' object has no attribute 'filter'