We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from ninja import Query, Field class InstrumentFilter(FilterSchema): symbol: Optional[str] = Field(None, q='symbol__icontains')
Here I get "No parameter named 'q'" on Field
@router.get('/instruments', response=List[InstrumentSchema]) @paginate def instruments(request, filters: InstrumentFilter = Query(...)): ...
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!
The text was updated successfully, but these errors were encountered:
ninja.Field is actually pydantic.Field, pydantic V2 Field extra kwargs is deprecated.
ninja.Field
pydantic.Field
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"})
https://github.com/vitalik/django-ninja/blob/master/docs/docs/whatsnew_v1.md#shorter--cleaner-parameters-syntax
You can use shorter parameters syntax to fix this typing error
@router.get("/instruments", response=List[InstrumentSchema]) @paginate def instruments( request, filters: Query[InstrumentFilter], # <--- !!! ): ...
Sorry, something went wrong.
Thanks, that fixes the Pyright complaints. I take it the NinjaAPI docs on this topic need a little update then?
No branches or pull requests
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!
The text was updated successfully, but these errors were encountered: