我有这个tastypie资源:
class BlogPostResource(ModelResource):
comments = fields.ToManyField('comments.api.CommentResource', 'comments', full=True)
博客端点/api/v1/blog/13
给出以下回复:
{
id: 13,
text: 'blog example',
comments: [{id: 1, comment: "1"},{id: 2, comment: "2"}, ...]
}
我期待评论像这样分页:
{
id: 13,
text: 'blog example',
comments:{
meta: {
limit: 20,
next: "/api/v1/comment/?offset=20&limit=20&format=json",
offset: 0,
previous: null,
total_count: 36
},
objects: [{id: 1, comment: "1"},{id: 2, comment: "2"}, ...]
}
}
如何对评论进行分页以获得我期待的响应?