Closed balmasea closed 9 months ago
Solution:
class Feature(AuditMixin, Model):
__versioned__ = {}
id = Column(Integer, primary_key=True)
name = Column(String, unique=True, nullable=False)
created_by_fk = Column(Integer, ForeignKey("ab_user.id"), default=AuditMixin.get_user_id, nullable=False)
changed_by_fk = Column(Integer, ForeignKey("ab_user.id"), default=AuditMixin.get_user_id, nullable=False)
created_by_user = relationship("User", foreign_keys=[created_by_fk])
changed_by_user = relationship("User", foreign_keys=[changed_by_fk])
Thanks, it works like a charm!
Environment
Flask-Appbuilder version: 4.3.5
Describe the expected results
It should keep the changed_by_fk field populated in the database.
Describe the actual results
The fields in the database
created_by_fk
andchanged_by_fk
are null.Tell us what happens instead.
Steps to reproduce
Define a model inheriting from AuditMixin and redefine foreign keys: