Creating One-to-one Relationship Flask-sqlalchemy
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 name
Define function __repr__
of Department
.
classDepartment(db.Model)# ... column definitiondef__repr__(self):
returnself.name
The __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.
Post a Comment for "Creating One-to-one Relationship Flask-sqlalchemy"