How to return only one attribute of an object #810
Unanswered
J-Christophe
asked this question in
Q&A
Replies: 1 comment
-
use |
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
-
Hi,
I am beginner with Tortoise/Pydantic and I spent a lot of time to find how to return only one attribute of an object but without success. Based on the example that is provided in the documentation, I would like to return only the name of the user and not the full object. Could you explain me how to do please ?
@app.get(
"/user/{user_id}", response_model=User_Pydantic, responses={404: {"model": HTTPNotFoundError}}
)
async def get_user(user_id: int):
return await User_Pydantic.from_queryset_single(Users.get(id=user_id))
Thanks for your support
Jean-Christophe
Beta Was this translation helpful? Give feedback.
All reactions