Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 13 for UserBase (0.1 sec)

  1. docs_src/extra_models/tutorial002.py

    from fastapi import FastAPI
    from pydantic import BaseModel, EmailStr
    
    app = FastAPI()
    
    
    class UserBase(BaseModel):
        username: str
        email: EmailStr
        full_name: Union[str, None] = None
    
    
    class UserIn(UserBase):
        password: str
    
    
    class UserOut(UserBase):
        pass
    
    
    class UserInDB(UserBase):
        hashed_password: str
    
    
    def fake_password_hasher(raw_password: str):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 824 bytes
    - Viewed (0)
  2. tests/test_response_model_data_filter.py

    app = FastAPI()
    
    
    class UserBase(BaseModel):
        email: str
    
    
    class UserCreate(UserBase):
        password: str
    
    
    class UserDB(UserBase):
        hashed_password: str
    
    
    class PetDB(BaseModel):
        name: str
        owner: UserDB
    
    
    class PetOut(BaseModel):
        name: str
        owner: UserBase
    
    
    @app.post("/users/", response_model=UserBase)
    async def create_user(user: UserCreate):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 1.7K bytes
    - Viewed (0)
  3. docs_src/extra_models/tutorial002_py310.py

    from fastapi import FastAPI
    from pydantic import BaseModel, EmailStr
    
    app = FastAPI()
    
    
    class UserBase(BaseModel):
        username: str
        email: EmailStr
        full_name: str | None = None
    
    
    class UserIn(UserBase):
        password: str
    
    
    class UserOut(UserBase):
        pass
    
    
    class UserInDB(UserBase):
        hashed_password: str
    
    
    def fake_password_hasher(raw_password: str):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 792 bytes
    - Viewed (0)
  4. docs_src/sql_databases_peewee/sql_app/schemas.py

    class Item(ItemBase):
        id: int
        owner_id: int
    
        class Config:
            orm_mode = True
            getter_dict = PeeweeGetterDict
    
    
    class UserBase(BaseModel):
        email: str
    
    
    class UserCreate(UserBase):
        password: str
    
    
    class User(UserBase):
        id: int
        is_active: bool
        items: List[Item] = []
    
        class Config:
            orm_mode = True
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 868 bytes
    - Viewed (0)
  5. docs/zh/docs/tutorial/extra-models.md

    辅助的附加函数只是为了演示可能的数据流,但它们显然不能提供任何真正的安全机制。
    
    ///
    
    ## 减少重复
    
    **FastAPI** 的核心思想就是减少代码重复。
    
    代码重复会导致 bug、安全问题、代码失步等问题(更新了某个位置的代码,但没有同步更新其它位置的代码)。
    
    上面的这些模型共享了大量数据,拥有重复的属性名和类型。
    
    FastAPI 可以做得更好。
    
    声明 `UserBase` 模型作为其它模型的基类。然后,用该类衍生出继承其属性(类型声明、验证等)的子类。
    
    所有数据转换、校验、文档等功能仍将正常运行。
    
    这样,就可以仅声明模型之间的差异部分(具有明文的 `password`、具有 `hashed_password` 以及不包括密码)。
    
    通过这种方式,可以只声明模型之间的区别(分别包含明文密码、哈希密码,以及无密码的模型)。
    
    //// tab | Python 3.10+
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.6K bytes
    - Viewed (0)
  6. docs/em/docs/tutorial/extra-models.md

    ///
    
    ## 📉 ❎
    
    📉 📟 ❎ 1️⃣ 🐚 💭 **FastAPI**.
    
    📟 ❎ 📈 🤞 🐛, 💂‍♂ ❔, 📟 🔁 ❔ (🕐❔ 👆 ℹ 1️⃣ 🥉 ✋️ 🚫 🎏), ♒️.
    
    & 👉 🏷 🌐 🤝 📚 💽 & ❎ 🔢 📛 & 🆎.
    
    👥 💪 👻.
    
    👥 💪 📣 `UserBase` 🏷 👈 🍦 🧢 👆 🎏 🏷. & ⤴️ 👥 💪 ⚒ 🏿 👈 🏷 👈 😖 🚮 🔢 (🆎 📄, 🔬, ♒️).
    
    🌐 💽 🛠️, 🔬, 🧾, ♒️. 🔜 👷 🛎.
    
    👈 🌌, 👥 💪 📣 🔺 🖖 🏷 (⏮️ 🔢 `password`, ⏮️ `hashed_password` & 🍵 🔐):
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.8K bytes
    - Viewed (0)
  7. docs/en/docs/tutorial/extra-models.md

    And these models are all sharing a lot of the data and duplicating attribute names and types.
    
    We could do better.
    
    We can declare a `UserBase` model that serves as a base for our other models. And then we can make subclasses of that model that inherit its attributes (type declarations, validation, etc).
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 7.7K bytes
    - Viewed (0)
  8. docs/ru/docs/tutorial/extra-models.md

    А все описанные выше модели используют много общих данных и дублируют названия атрибутов и типов.
    
    Мы можем это улучшить.
    
    Мы можем определить модель `UserBase`, которая будет базовой для остальных моделей. И затем мы можем создать подклассы этой модели, которые будут наследовать её атрибуты (объявления типов, валидацию, и т.п.).
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 11.5K bytes
    - Viewed (0)
  9. docs/pt/docs/tutorial/extra-models.md

    E esses modelos estão compartilhando muitos dos dados e duplicando nomes e tipos de atributos.
    
    Nós poderíamos fazer melhor.
    
    Podemos declarar um modelo `UserBase` que serve como base para nossos outros modelos. E então podemos fazer subclasses desse modelo que herdam seus atributos (declarações de tipo, validação, etc.).
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 7.8K bytes
    - Viewed (0)
  10. docs/de/docs/tutorial/extra-models.md

    Unsere Modelle teilen alle eine Menge der Daten und verdoppeln Attribut-Namen und -Typen.
    
    Das können wir besser machen.
    
    Wir deklarieren ein `UserBase`-Modell, das als Basis für unsere anderen Modelle dient. Dann können wir Unterklassen erstellen, die seine Attribute (Typdeklarationen, Validierungen, usw.) erben.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.7K bytes
    - Viewed (0)
Back to top