Use a relationship object attribute in ModelView (how to avoid "AttributeError while querying") #426
Unanswered
laurent-leconte
asked this question in
Q&A
Replies: 1 comment
-
|
Hello and thank you, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
just discovered the sqladmin library, kudos on a great tool!
I wonder if it's possible to access and display a relationship object's attribute in a ModelView?
Consider the following model:
I can define a view model for AugmentedUser that links to User:
However, I want to display the
User.emailattribute, rather than theUserobject.The following code doesn't work.
This raises
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with AugmentedUser.user has an attribute 'email'.This Stack Overflow question indicates that this is an SQLAlchemy error that can be fixed by accessing the instance (through a join) rather than the class. Is there any way to do this with SQLAdmin?
Beta Was this translation helpful? Give feedback.
All reactions