Closed Bishwas-py closed 4 months ago
Let's assume below view_func returns empty data:
@djapify @paginate(OffsetLimitPagination) def get_post_comments(request, source_id: int, **kwargs) -> list[CommentSchema]: post = Post.objects.get(id=source_id) comments_and_replies = PolymorphicComments.objects.filter( parent_type=ContentType.objects.get_for_model(post), parent_id=post.id ) return comments_and_replies.alive()
{"error": [{"type": "model_attributes_type", "loc": ["response"], "msg": "Input should be a valid dictionary or object to extract fields from", "input": [], "url": "https://errors.pydantic.dev/2.5/v/model_attributes_type"}], "error_count": 1, "title": "output"}
Can be fixed by:
In pagination/offset_pagination.py, line 46, replace return [] with:
pagination/offset_pagination.py, line 46
return []
return { "items": [], "offset": offset, "limit": limit, "has_next": False, "has_previous": False, "total_pages": 0, }
Let's assume below view_func returns empty data:
Can be fixed by:
In
pagination/offset_pagination.py, line 46
, replacereturn []
with: