Thanks for IPRoyal for sponsoring this video! Get 30% off any Royal Residential Proxies by following this link and using code *"CARBERRA"* at checkout! iproyal.club/carberra
@antonzimin3999 Жыл бұрын
To convert the field name, you can use the simplest way. Use 'Field(alias="....")' from pydantic import BaseModel, Field class Example(BaseModel): pythonic_field: str = Field(alias="CamelCaseField") resp = {"CamelCaseField": "cool"} p = Example(**resp) print(p)
@parikshitrao2948 Жыл бұрын
Honestly this looks like you have to do this for every field but here its generalised, if the data keys are less then it would be fine but if you have a lot of keys, its a headache
@redsolaris1 Жыл бұрын
that basemodel class is borrowed from typescript Interfaces
@IwoGda Жыл бұрын
You can make gt, ge etc. validators automatically by using =Field()