rest api是在没有count或results属性的情况下生成的

时间:2015-12-24 10:26:01

标签: json django rest django-rest-framework

我使用django rest framework创建了一个api,但正在呈现的api不包含可以使用的countresultnextnull属性访问循环中的几个字段。它看起来像这样 -

[
{
    "url": "http://127.0.0.1:8000/app/clubs/1/persons/",
    "id": 1,
    "club_name": "club1",
    "persons": [
        1,
        2
    ]
},
{
    "url": "http://127.0.0.1:8000/app/clubs/2/persons/",
    "id": 2,
    "club_name": "club2",
    "persons": [
        1,
        4
    ]
},
]

但是网络上的所有教程都有这些属性的api。我想访问俱乐部的所有属性是一个循环。有没有我错过的东西?

1 个答案:

答案 0 :(得分:3)

您需要为您的API设置pagination

请注意,API已更改,某些帖子可能与当前API不同。