Skip to content

Commit fc7a068

Browse files
committed
📝 Update release notes
1 parent 3a3879b commit fc7a068

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/en/docs/release-notes.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,40 @@ hide:
77

88
## Latest Changes
99

10+
FastAPI now (temporarily) supports both Pydantic v2 models and `pydantic.v1` models at the same time in the same app, to make it easier for any FastAPI apps still using Pydantic v1 to gradually but quickly **migrate to Pydantic v2**.
11+
12+
```Python
13+
from fastapi import FastAPI
14+
from pydantic import BaseModel as BaseModelV2
15+
from pydantic.v1 import BaseModel
16+
17+
18+
class Item(BaseModel):
19+
name: str
20+
description: str | None = None
21+
22+
23+
class ItemV2(BaseModelV2):
24+
title: str
25+
summary: str | None = None
26+
27+
28+
app = FastAPI()
29+
30+
31+
@app.post("/items/", response_model=ItemV2)
32+
def create_item(item: Item):
33+
return {"title": item.name, "summary": item.description}
34+
```
35+
36+
Adding this feature was a big effort with the main objective of making it easier for the few applications still stuck in Pydantic v1 to migrate to Pydantic v2.
37+
38+
And with this, support for **Pydantic v1 is now deprecated** and will be **removed** from FastAPI in a future version soon.
39+
40+
**Note**: have in mind that the Pydantic team already stopped supporting Pydantic v1 for recent versions of Python, starting with Python 3.14.
41+
42+
You can read in the docs more about how to [Migrate from Pydantic v1 to Pydantic v2](https://fastapi.tiangolo.com/how-to/migrate-from-pydantic-v1-to-pydantic-v2/).
43+
1044
### Features
1145

1246
* ✨ Add support for `from pydantic.v1 import BaseModel`, mixed Pydantic v1 and v2 models in the same app. PR [#14168](https://github.com/fastapi/fastapi/pull/14168) by [@tiangolo](https://github.com/tiangolo).

0 commit comments

Comments
 (0)