Skip to content

Should I use Schema.model_dump() or Schema.dict()? #1538

@darshan-roon

Description

@darshan-roon

Hi, I'm trying to figure out what the best method to use is for the latest version of Dango Ninja.

Example:

class EducationUpdatePayload(Schema):
    type: EducationType | None = Field(
        None, description="The type of education entry.", example=EducationType.MEDICAL_SCHOOL
    )
    institution_name: str | None = Field(
        None, description="The name of the institution.", example="University of California, San Francisco"
    )
    start_year: int | None = Field(None, description="The year the education started.", example=2010)
    end_year: int | None = Field(
        None, description="The year the education ended. If None, the education is still ongoing.", example=2014
    )

payload = EducationUpdatePayload(...)

payload.model_dump() OR payload.dict()?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions