Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 38 for model_dump (0.06 sec)

  1. docs_src/body/tutorial004_py310.py

        price: float
        tax: float | None = None
    
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def update_item(item_id: int, item: Item, q: str | None = None):
        result = {"item_id": item_id, **item.model_dump()}
        if q:
            result.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 414 bytes
    - Viewed (0)
  2. docs_src/body/tutorial002_py39.py

        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
    
    
    app = FastAPI()
    
    
    @app.post("/items/")
    async def create_item(item: Item):
        item_dict = item.model_dump()
        if item.tax is not None:
            price_with_tax = item.price + item.tax
            item_dict.update({"price_with_tax": price_with_tax})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 485 bytes
    - Viewed (0)
  3. docs_src/body/tutorial004_py39.py

        tax: Union[float, None] = None
    
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def update_item(item_id: int, item: Item, q: Union[str, None] = None):
        result = {"item_id": item_id, **item.model_dump()}
        if q:
            result.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 458 bytes
    - Viewed (0)
  4. docs/pt/docs/tutorial/body.md

    /// info | Informação
    
    No Pydantic v1 o método se chamava `.dict()`, ele foi descontinuado (mas ainda é suportado) no Pydantic v2, e renomeado para `.model_dump()`.
    
    Os exemplos aqui usam `.dict()` para compatibilidade com o Pydantic v1, mas você deve usar `.model_dump()` se puder usar o Pydantic v2.
    
    ///
    
    ## Corpo da requisição + parâmetros de rota { #request-body-path-parameters }
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 7.9K bytes
    - Viewed (0)
  5. docs_src/extra_models/tutorial001_py310.py

    def fake_password_hasher(raw_password: str):
        return "supersecret" + raw_password
    
    
    def fake_save_user(user_in: UserIn):
        hashed_password = fake_password_hasher(user_in.password)
        user_in_db = UserInDB(**user_in.model_dump(), hashed_password=hashed_password)
        print("User saved! ..not really")
        return user_in_db
    
    
    @app.post("/user/", response_model=UserOut)
    async def create_user(user_in: UserIn):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 905 bytes
    - Viewed (0)
  6. docs/es/docs/tutorial/extra-models.md

    /// info | Información
    
    En Pydantic v1 el método se llamaba `.dict()`, fue deprecado (pero aún soportado) en Pydantic v2, y renombrado a `.model_dump()`.
    
    Los ejemplos aquí usan `.dict()` para compatibilidad con Pydantic v1, pero deberías usar `.model_dump()` en su lugar si puedes usar Pydantic v2.
    
    ///
    
    ### Acerca de `**user_in.dict()` { #about-user-in-dict }
    
    #### `.dict()` de Pydantic { #pydantics-dict }
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Dec 16 16:33:45 UTC 2025
    - 7.6K bytes
    - Viewed (0)
  7. docs_src/extra_models/tutorial001_py39.py

    def fake_password_hasher(raw_password: str):
        return "supersecret" + raw_password
    
    
    def fake_save_user(user_in: UserIn):
        hashed_password = fake_password_hasher(user_in.password)
        user_in_db = UserInDB(**user_in.model_dump(), hashed_password=hashed_password)
        print("User saved! ..not really")
        return user_in_db
    
    
    @app.post("/user/", response_model=UserOut)
    async def create_user(user_in: UserIn):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 949 bytes
    - Viewed (0)
  8. docs/pt/docs/tutorial/response-model.md

    }
    ```
    
    /// info | Informação
    
    No Pydantic v1, o método era chamado `.dict()`, ele foi descontinuado (mas ainda suportado) no Pydantic v2 e renomeado para `.model_dump()`.
    
    Os exemplos aqui usam `.dict()` para compatibilidade com Pydantic v1, mas você deve usar `.model_dump()` em vez disso se puder usar Pydantic v2.
    
    ///
    
    /// info | Informação
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 17.3K bytes
    - Viewed (0)
  9. docs_src/sql_databases/tutorial002_py39.py

    ):
        hero_db = session.get(Hero, hero_id)
        if not hero_db:
            raise HTTPException(status_code=404, detail="Hero not found")
        hero_data = hero.model_dump(exclude_unset=True)
        hero_db.sqlmodel_update(hero_data)
        session.add(hero_db)
        session.commit()
        session.refresh(hero_db)
        return hero_db
    
    
    @app.delete("/heroes/{hero_id}")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  10. docs/ru/docs/tutorial/body.md

    /// info | Информация
    
    В Pydantic v1 метод назывался `.dict()`, в Pydantic v2 он был помечен как устаревший (но всё ещё поддерживается) и переименован в `.model_dump()`.
    
    Примеры здесь используют `.dict()` для совместимости с Pydantic v1, но если вы можете использовать Pydantic v2, используйте `.model_dump()`.
    
    ///
    
    ## Тело запроса + параметры пути { #request-body-path-parameters }
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 11.6K bytes
    - Viewed (0)
Back to top