[BUG] pydantic.errors.PydanticUserError: `QueryParams` is not fully defined; you should define `ModelFilterSchema`, then call `QueryParams.model_rebuild()`.
Author: tomas-antal-icCreated Apr 20, 2026Updated Jun 4, 2026
Describe the bug There seems to be an issue with paginated and filtered endpoints.
While this works:
@api.get("/models", response=List[ModelSchema])
def list_models(request, filters: ModelFilterSchema = Query(...)) -> List[ModelSchema]:
models = Model.objects.all()
models = filters.filter(models)
return modelsAnd this also works:
@api.get("/models", response=List[ModelSchema])
@paginate
def list_models(request):
models = Model.objects.all()
return modelsThis one fails:
@api.get("/models", response=List[ModelSchema])
@paginate
def list_models(request, filters: ModelFilterSchema = Query(...)) -> List[ModelSchema]:
models = Model.objects.all()
models = filters.filter(models)
return modelspydantic.errors.PydanticUserError: `QueryParams` is not fully defined; you should define `ModelFilterSchema`, then call `QueryParams.model_rebuild()`.
(Note, "Model" is just a placeholder here)
Versions:
- Python version: 3.10
- Django version: 5.2.13
- Django-Ninja version: 1.6.2
- Pydantic version: 2.12.5
Source: vitalik/django-ninja