Replies: 1 comment 2 replies
-
Adding relationship in the public interface seems to work: ...
class HeroPublicWithTeam(HeroPublic):
team: "TeamPublic | None" = Relationship() ...
class TeamPublicWithHeroes(TeamPublic):
heroes: List["HeroPublic"] = Relationship() Side note: You do not need |
Beta Was this translation helpful? Give feedback.
2 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.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
(the only effective change I did seems to be changing the type signature of the fields in
TeamPublicWithHeroes
andHeroPublicWithTeam
from direct to the indirect python "string" types, in bothmodels.py
files. It worked fine before I split it up, or when commenting out or changing the type of the stringified field types.)Splitting up the example code from https://sqlmodel.tiangolo.com/tutorial/fastapi/relationships/ to multiple files, i.e. in the following way:
Description
Will result in the following error when attempting to view the swagger spec:
which shows up as

in
http://localhost:8000/api/docs#/
Operating System
Linux, Windows
Operating System Details
Also tested on a Win11 machine with Ubuntu WSL with the same result.
SQLModel Version
0.0.22
Python Version
3.12.8
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions