The business logic - One Category may have multiple (1:M) attributes, like Category \"Memory\" could have attributes Speed, Size, Type etc.
at the same time one Cat
Okay found the answer - use post_update in relationship http://docs.sqlalchemy.org/en/latest/orm/relationship_persistence.html#post-update
so what I did is inside Category class is changed this:
SortByAttribute = relationship(
"Attribute",
uselist=False,
foreign_keys=[sortByAttribute],
primaryjoin="Attribute.ID==Category.sortByAttribute"
)
to this:
SortByAttribute = relationship(
"Attribute",
uselist=False,
foreign_keys=[sortByAttribute],
primaryjoin="Attribute.ID==Category.sortByAttribute",
post_update=True
)