Open uniqpr0 opened 2 months ago
I think this is a more general Pydantic issue. I am having the same problem in my fastapi application. Correction: solved in 2.9.0!
I think this is a more general Pydantic issue. I am having the same problem in my fastapi application. Correction: solved in 2.9.0!
Actually i solved it like that in example with mongodb version Pydantic 2.6.1 and Fastui 0.6.0
from fastui.forms import fastui_form, SelectSearchResponse
class CityAdd(BaseModel):
city: str = Field(json_schema_extra={'search_url': '/city/search'}, title='City')
@app.get('/city/search', response_model=SelectSearchResponse)
async def search_view(request: Request, q: str | None = None) -> SelectSearchResponse:
if q is None:
cities = citiesListEntity(await (request.app.database.city.find()).to_list(None))
else:
cities = citiesListEntity(await (request.app.database.city.find({"name": {"$regex": q}})).to_list(None))
@app.get("/api/city/add", response_model=FastUI, response_model_exclude_none=True)
async def add_city_page(request: Request):
return [
c.Page(
components=[
c.Link(components=[c.Button(text='Return')], on_click=BackEvent()),
c.Heading(text='Add city', level=2),
c.ModelForm(
model=CityAdd,
submit_url="/api/city/create",
)
]
)
]
@app.post('/api/city/create', response_model=FastUI, response_model_exclude_none=True)
async def city_create(request: Request,
payload: Annotated[CityAdd, fastui_form(CityAdd)],):
print(payload.model_dump())
return [c.FireEvent(event=GoToEvent(url='/cities'))]
I'm trying to use that part of code from example
But error
pydantic 2.8.2 pydantic-core 2.23.1
What is the problem?