Open krims0n32 opened 4 days ago
ninja.Field
is actually pydantic.Field
, pydantic V2 Field extra kwargs is deprecated.
https://docs.pydantic.dev/2.9/migration/#changes-to-pydanticfield https://github.com/pydantic/pydantic/blob/8bad227e7557519307a9ea9b0ca129aca1997667/pydantic/fields.py#L1025-L1033 https://github.com/pydantic/pydantic/blob/8bad227e7557519307a9ea9b0ca129aca1997667/pydantic/fields.py#L685-L686
So this will fix this typing error
class InstrumentFilter(FilterSchema):
symbol: str | None = Field(None, json_schema_extra={"q": "symbol__icontains"})
You can use shorter parameters syntax to fix this typing error
@router.get("/instruments", response=List[InstrumentSchema])
@paginate
def instruments(
request,
filters: Query[InstrumentFilter], # <--- !!!
): ...
Here I get "No parameter named 'q'" on Field
And here I get "Object of type Annotated is not callable" on Query.
I followed the docs on filtering. Am I doing something wrong here, missing a package?
Thanks!