My admin page
when I want to edit User, I see that Serv - orm.relation("Services", back_populates='user')
shows in non-human readable text.
This is my model:
class User(SqlAlchemyBase, UserMixin, SerializerMixin):
__tablename__ = 'users'
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True, nullable=False)
..
serv = orm.relation("Services", back_populates='user')
def __repr__(self):
return self.name
What function I have to include?
You haven't defined either a __repr__
method or __str__
method for your Services
model.
See this SO QA, Difference between str and repr?. Note the summary in the answer:
Implement
__repr__
for any class you implement. This should be second nature. Implement__str__
if you think it would be useful to have a string version which errs on the side of readability.