我想为我博客中的所有文章创建一个年度存档,并将其作为JSON传递给我的应用程序。你知道吗
我在找下面的东西。你知道吗
[
{
year:2017
url:
numbrofposts: 100
months: [
{
month: Jan
numberofposts: 10
url:
listofposts: [
{ id:, title,url}
{ id:, title,url}
]
}
]
}
{
year:2016
numbrofposts: 500
months: [
{
month: Jan
numberofposts: 30
listofposts: [
{ id:, title, description, etc}
{ id:, title, description, etc}
]
}
]
}
...
]
如果可能的话,如何添加分页,因为在未来的职位数量将不断增加。我不确定分页是基于年还是基于月
假设我有一个简单的Posts模型,有标题、描述和创建日期
试试这个:
序列化程序.py
视图.py
我建议查看分页指南:http://www.django-rest-framework.org/api-guide/pagination/
从该指南中:
我目前正在使用for循环创建JSON,如下所示。你知道吗
以上是有效的查询方式还是有更好的方式。你知道吗
我得到以下结果
我不知道如何添加分页从哪个级别年或月或职位。如果我尝试了一个月或帖子如何显示在下一页的继续
相关问题 更多 >
编程相关推荐