Error fastapi.exceptions.ResponseValidationError and other relationship and back_population problems #636
Replies: 3 comments
-
I still didn't found a solution... somebody have any idea? |
Beta Was this translation helpful? Give feedback.
-
Hi @diegocgaona, I fixed the error by eager loading what I needed in the query itself before returning the object. So adding to your query sqlAlchemy |
Beta Was this translation helpful? Give feedback.
-
Thanks!! I will see to it, but I think I will wait to do a production implementation of the library until it is complete. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
First, if I try to use my code with the
@router.get("/", response_model=List[ClientsRead])
, I get an error:I don't have any idea what is the field or problem with my schemas, I tried to follow the way the tutorial show, but I think I missed something because of this error.
If I try
@router.get("/")
(withoutresponse_model
) my response in the/docs
not show the related fieldsnotes
orjobs
, (and I had records related, I see using sqlite browser) the other fields are fine.In my
print(client_list.dict)
orprint(client_list.jobs)
I can see the related jobs for example. But in myprint(client_list.json())
, thejobs
field do not appears.What I'm doing wrong? Why my
response_model
does not work and why I can't see the related data in my response/json?I tried to found solutions, but I couldn't find a really similar issue, and I tried some things I found, but without success...
Another question (less important, is a doubt) I was using Tortoise ORM and now I'm trying to migrate to SQLModel and I was using the filters as above, they came as parameters in my url from my front end and I was using a dict and strings to make the filters. It is possible to do something this way with SQLModels? I can filter using strings? O another way to filter using the query parameters that are not
None
or that appears in my request?My best regards, Diego.
Operating System
Linux
Operating System Details
Ubuntu 20.4 under WSL on Windows 11
SQLModel Version
0.08
Python Version
3.11.4
Additional Context
Other packages version:
SQLAlchemy: 1.4.41
FastAPI: 0.101.0
Pydantic: 1.10.12
Uvicorn: 0.23.2
Starlette: 0.27.0
Beta Was this translation helpful? Give feedback.
All reactions