from pydantic import BaseModel class CustomConfig: populate_by_name = True from_attributes = True class CustomModel(BaseModel): class Config: from_attributes = True