Skip to content

Commit

Permalink
migrating to Meta/model_config
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalik committed Apr 30, 2024
1 parent 5b4c006 commit 9f9b1e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions tests/demo_project/someapp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@


class EventSchema(BaseModel):
model_config = dict(from_attributes=True)

title: str
start_date: date
end_date: date

class Config:
from_attributes = True


@router.post("/create", url_name="event-create-url-name")
def create_event(request, event: EventSchema):
Expand Down
9 changes: 5 additions & 4 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ class UserModel(BaseModel):
user_name: str
# skipping password output to responses

class Config:
from_attributes = True
alias_generator = to_camel
populate_by_name = True
model_config = dict(
from_attributes=True,
alias_generator=to_camel,
populate_by_name=True,
)


@router.get("/check_model", response=UserModel)
Expand Down

0 comments on commit 9f9b1e1

Please sign in to comment.