Hi Andreas, On Fri, Jan 15, 2016 at 02:56:39AM -0800, Andreas Jung wrote: > Hi, > > I currently have the following mix-in class construction (based on the > documentation > http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html > ) > > Base = declarative_base() > > class BaseCountry(object): > """ Managed through Kotti """ > > @declared_attr > def __tablename__(cls): > return cls.__name__.lower() > > dpis_id = Column(Integer, primary_key=True) > title = Column(Unicode(80)) > regions = relationship("Region", > primaryjoin="Country.dpis_id==Region.country_id")
As the error message in the exception says, this attribute needs to be declared as a declared_attr, like this: @declared_attr def regions(cls): return relationship("Region", primaryjoin="Country.dpis_id==Region.country_id") This is stated in the following section of the docs: http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html#mixing-in-relationships Good luck, Michal > "Mapper properties (i.e. deferred," > sqlalchemy.exc.InvalidRequestError: Mapper properties (i.e. > deferred,column_property(), relationship(), etc.) must be declared as > @declared_attr callables on declarative mixin > classes. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: Digital signature