Creating One-to-one Relationship Flask-sqlalchemy August 30, 2023 Post a Comment I am trying to create a one-to-one relationship between a Department & Ticket table. This way when looking inside of Flask-Admin a user would be able to see the Department nameSolution 1: Define function __repr__ of Department.classDepartment(db.Model)# ... column definitiondef__repr__(self): returnself.name CopyThe __repr__ will show the name of department instead the inner representation of object.PS: uselist=0 is the key to define a one to one relationship in SQLAlchemy. Share Post a Comment for "Creating One-to-one Relationship Flask-sqlalchemy"
Post a Comment for "Creating One-to-one Relationship Flask-sqlalchemy"