BaseModel

noun

say it: “BAYS MOD-ul” /beɪs ˈmɑdəl/

The Pydantic class your data models inherit from; each field is written as a class attribute with a type hint.

What is BaseModel?

BaseModel is the Pydantic class your data models inherit from. Each field is a class attribute with a type hint.

from pydantic import BaseModel

class RecipeIn(BaseModel):
    title: str
    minutes: int
    vegetarian: bool = False

In a sentence

  • “class Application(BaseModel) gave the API its checked request model.”
  • “Every request and response model in the course inherits from BaseModel.”

Level: Apprentice · More FastAPI terms at this level

Updated