-
First Check
Commit to Help
Example Code@app.post("/book", status_code=status.HTTP_201_CREATED, response_model = Post)
def create_book():
...
class Book(BaseModel):
title: str
content: strDescriptionI hope this message finds you well. I've been using FastAPI and noticed a potential need for an update in the documentation regarding Pydantic usage. Specifically, with the latest version of Pydantic (2.0), the orm_mode attribute in the Config class of a Pydantic model is no longer required when setting the response_model argument. In the official FastAPI documentation under the section https://fastapi.tiangolo.com/tutorial/sql-databases/#use-pydantics-orm_mode, it still mentions the use of orm_mode = True. However, as of Pydantic 2.0, this is no longer necessary. I wanted to bring this to your attention and inquire if there are plans to update the documentation. If needed, I am more than willing to contribute to this update. Please let me know your thoughts on this matter. Operating SystemWindows Operating System DetailsNo response FastAPI Version0.109.0 Pydantic Version2.5.3 Python Version3.11.0 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
The docs are in a state that supports both Pydantic v1 and v2. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your swift response, Kludex. Indeed, I acknowledge that the documentation is designed to accommodate both versions of Pydantic. However, considering that the latest version of FastAPI defaults to downloading Pydantic 2.5.3, it would be beneficial to align the documentation with the latest functionalities introduced in Pydantic. For instances where an older version of FastAPI utilizes Pydantic v1, the existing documentation can be referenced. It's worth noting that Pydantic is on the verge of releasing version 3, rendering functionalities of v1 obsolete. Hence, updating the FastAPI documentation to reflect the Pydantic version bundled with the current FastAPI installation would be a prudent approach. What do you think about it? |
Beta Was this translation helpful? Give feedback.
-
|
I agree with the opinion that the documentation should reflect the current version, but see the note section on the top of that page:
I think this makes it clear that the authors are aware of the issue and have an update in the pipeline. Just have patience. 🙂 |
Beta Was this translation helpful? Give feedback.

I agree with the opinion that the documentation should reflect the current version, but see the note section on the top of that page:
I think this makes it clear that the authors are aware of the issue and have an update in the pipeline. Just have patience. 🙂