Why do you want to have the relationship in the base? I've simply omitted them from there, as inherit Base to the Create models, which are the POST data that the frontend uses to create objects. Then Read models have such definitions for the relationships that we wanna expose in the API.
I'm using the base model to represent a subset of data useful for certain operations that don't require connection to a database or the entire model to be present.
Yep, you shouldn't do that. If a descendant of the base class is completely overriding the field, then it should probably not be there. In this particular case, it should certainly not be there on the base class.
You would have one field for the table model and another field for the class that inherits from base that needs the relationship.
If you want to avoid duplicating the field with relationships you would need a base for everything, and another "sub-base" only for data models (not tables) that includes the relationship.
Activity
antont commented on Oct 21, 2022
Why do you want to have the relationship in the base? I've simply omitted them from there, as inherit Base to the Create models, which are the POST data that the frontend uses to create objects. Then Read models have such definitions for the relationships that we wanna expose in the API.
jtpavlock commented on Oct 21, 2022
I'm using the base model to represent a subset of data useful for certain operations that don't require connection to a database or the entire model to be present.
tiangolo commented on Oct 21, 2022
Yep, you shouldn't do that. If a descendant of the base class is completely overriding the field, then it should probably not be there. In this particular case, it should certainly not be there on the base class.
You would have one field for the table model and another field for the class that inherits from base that needs the relationship.
If you want to avoid duplicating the field with relationships you would need a base for everything, and another "sub-base" only for data models (not tables) that includes the relationship.
github-actions commented on Nov 1, 2022
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.