Pagination and sorting
Pagination
Section titled “Pagination”All API endpoints that list a resource (for example List all users) return paginated results in the following structure:
{ "count": 42, "next": "https://api.schulungstool.de/v1/users/?page=3", "previous": "https://api.schulungstool.de/v1/users/?page=1", "results": ["..."]}| Key | Value |
|---|---|
count |
integer – total number of results found |
next |
string <url> or null – URL of the next page, if any |
previous |
string <url> or null – URL of the previous page, if any |
results |
array <object> – the objects of the current page |
A page contains at most 25 results.
Use the query parameter page to choose which page is returned. By default this is the
first page (page=1). For example, retrieve the third page with ?page=3.
Sorting
Section titled “Sorting”When listing a resource, you can control the sort order of the results: use the query
parameter ordering to set one field or several fields (comma-separated) to sort by.
Results can be sorted ascending (ordering=fieldname) and descending
(ordering=-fieldname) by prefixing the field name with a -.
Examples:
- Sort courses by name:
ordering=name: ascending by nameordering=-name: descending by name
- Sort participations by due date and course name:
ordering=due_date,course: ascending by due date, then ascending by course nameordering=-due_date,course: descending by due date, then ascending by course name
Which fields are sortable per endpoint is shown by the ordering parameter of the
respective endpoint in the API reference.